pipeline-moe 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +26 -0
- package/LICENSE +21 -0
- package/README.md +408 -0
- package/bin/pipeline-moe.mjs +40 -0
- package/package.json +68 -0
- package/presets/2106BUILD.json +163 -0
- package/presets/CHEAPBUILD.json +97 -0
- package/presets/FREEROOM.json +96 -0
- package/presets/Versa.json +145 -0
- package/presets/cloud-main.json +76 -0
- package/presets/cloud-sprint.json +70 -0
- package/presets/local-default.json +152 -0
- package/presets/main.json +147 -0
- package/presets/mainmix.json +145 -0
- package/src/circuit-breaker.ts +141 -0
- package/src/config.ts +46 -0
- package/src/custom-tools/arxiv-search.ts +186 -0
- package/src/custom-tools/check-room.ts +45 -0
- package/src/custom-tools/destroy-room.ts +45 -0
- package/src/custom-tools/index.ts +75 -0
- package/src/custom-tools/spawn-room.ts +99 -0
- package/src/custom-tools/stop-room.ts +50 -0
- package/src/custom-tools/web-read.ts +104 -0
- package/src/custom-tools/web-search.ts +144 -0
- package/src/custom-tools/youcom-search.ts +230 -0
- package/src/custom-tools/youtube-transcript.ts +124 -0
- package/src/local-model-lock.ts +52 -0
- package/src/model.ts +131 -0
- package/src/orchestrator.ts +59 -0
- package/src/participant.ts +423 -0
- package/src/path-guard.ts +13 -0
- package/src/personas.ts +480 -0
- package/src/receipts.ts +120 -0
- package/src/registry.ts +317 -0
- package/src/room-manager.ts +505 -0
- package/src/room.ts +1657 -0
- package/src/sandbox-tools.ts +141 -0
- package/src/server.ts +1846 -0
- package/src/sse.ts +86 -0
- package/src/sshfs.ts +139 -0
- package/src/store.ts +79 -0
- package/src/types.ts +131 -0
- package/src/validation.ts +36 -0
- package/tsconfig.json +15 -0
- package/web/dist/assets/index-CmMGhMKG.css +1 -0
- package/web/dist/assets/index-LAGqbZII.js +41 -0
- package/web/dist/index.html +13 -0
- package/web/tsconfig.json +21 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Workspace-confined tools. pi's built-in file tools resolve relative paths
|
|
2
|
+
// against cwd but will happily honor an absolute path anywhere on disk (we saw
|
|
3
|
+
// an agent write to $HOME). For a multi-agent room we replace the built-ins
|
|
4
|
+
// with custom tools whose operations reject any path that escapes the workspace
|
|
5
|
+
// root, so file work — and therefore work receipts — stays inside the workspace.
|
|
6
|
+
//
|
|
7
|
+
// Note: `bash` cannot be hard-jailed without containerization; we pin its cwd to
|
|
8
|
+
// the workspace as a best effort. Treat bash as trusted-local only.
|
|
9
|
+
|
|
10
|
+
import { access as fsAccess, constants, mkdir, readFile, writeFile } from "node:fs/promises"
|
|
11
|
+
import { Type } from "typebox"
|
|
12
|
+
import {
|
|
13
|
+
createBashToolDefinition,
|
|
14
|
+
createEditToolDefinition,
|
|
15
|
+
createFindToolDefinition,
|
|
16
|
+
createGrepToolDefinition,
|
|
17
|
+
createLsToolDefinition,
|
|
18
|
+
createReadToolDefinition,
|
|
19
|
+
createWriteToolDefinition,
|
|
20
|
+
type ToolDefinition,
|
|
21
|
+
} from "@earendil-works/pi-coding-agent"
|
|
22
|
+
import type { AgentToolResult } from "@earendil-works/pi-coding-agent"
|
|
23
|
+
|
|
24
|
+
// Minimal text content type (mirrors pi-ai TextContent — not re-exported).
|
|
25
|
+
interface TextContent {
|
|
26
|
+
type: "text"
|
|
27
|
+
text: string
|
|
28
|
+
}
|
|
29
|
+
import { assertInside } from "./path-guard.js"
|
|
30
|
+
|
|
31
|
+
// ── ask_user tool ──────────────────────────────────────────────────────────
|
|
32
|
+
// Allows an agent to pause the pipeline and ask the user a clarifying question.
|
|
33
|
+
// The tool returns a confirmation message with terminate=true so the agent
|
|
34
|
+
// naturally stops its turn. The Room detects this tool call in the activity
|
|
35
|
+
// log and enters a "paused" state until the user responds.
|
|
36
|
+
|
|
37
|
+
const askUserSchema = Type.Object({
|
|
38
|
+
question: Type.String({ description: "The question to ask the user" }),
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
export function createAskUserToolDefinition(): ToolDefinition<typeof askUserSchema, undefined> {
|
|
42
|
+
return {
|
|
43
|
+
name: "ask_user",
|
|
44
|
+
label: "Ask User",
|
|
45
|
+
description:
|
|
46
|
+
"Pause the pipeline and ask the user a clarifying question. " +
|
|
47
|
+
"Use this when you need information only the user can provide — " +
|
|
48
|
+
"preferences, credentials, or context you cannot determine yourself. " +
|
|
49
|
+
"The pipeline will pause and wait for the user's response. " +
|
|
50
|
+
"Do not use this for rhetorical questions or self-clarification.",
|
|
51
|
+
parameters: askUserSchema,
|
|
52
|
+
async execute(_toolCallId, { question }) {
|
|
53
|
+
const content: TextContent[] = [{
|
|
54
|
+
type: "text",
|
|
55
|
+
text: `Question sent to user: "${question}". The pipeline is paused. Waiting for the user's response. When the user replies, their answer will be delivered to you as the next input.`,
|
|
56
|
+
}]
|
|
57
|
+
const result: AgentToolResult<undefined> = { content, details: undefined, terminate: true }
|
|
58
|
+
return result
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Build the confined tool definitions for the given built-in tool names. */
|
|
64
|
+
export function buildConfinedTools(root: string, toolNames: string[]): ToolDefinition[] {
|
|
65
|
+
const wanted = new Set(toolNames)
|
|
66
|
+
const tools: ToolDefinition[] = []
|
|
67
|
+
|
|
68
|
+
if (wanted.has("read")) {
|
|
69
|
+
tools.push(
|
|
70
|
+
createReadToolDefinition(root, {
|
|
71
|
+
operations: {
|
|
72
|
+
readFile: async (p) => {
|
|
73
|
+
assertInside(root, p)
|
|
74
|
+
return readFile(p)
|
|
75
|
+
},
|
|
76
|
+
access: async (p) => {
|
|
77
|
+
assertInside(root, p)
|
|
78
|
+
await fsAccess(p, constants.R_OK)
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}) as ToolDefinition,
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (wanted.has("write")) {
|
|
86
|
+
tools.push(
|
|
87
|
+
createWriteToolDefinition(root, {
|
|
88
|
+
operations: {
|
|
89
|
+
writeFile: async (p, content) => {
|
|
90
|
+
assertInside(root, p)
|
|
91
|
+
await writeFile(p, content)
|
|
92
|
+
},
|
|
93
|
+
mkdir: async (dir) => {
|
|
94
|
+
assertInside(root, dir)
|
|
95
|
+
await mkdir(dir, { recursive: true })
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
}) as ToolDefinition,
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (wanted.has("edit")) {
|
|
103
|
+
tools.push(
|
|
104
|
+
createEditToolDefinition(root, {
|
|
105
|
+
operations: {
|
|
106
|
+
readFile: async (p) => {
|
|
107
|
+
assertInside(root, p)
|
|
108
|
+
return readFile(p)
|
|
109
|
+
},
|
|
110
|
+
writeFile: async (p, content) => {
|
|
111
|
+
assertInside(root, p)
|
|
112
|
+
await writeFile(p, content)
|
|
113
|
+
},
|
|
114
|
+
access: async (p) => {
|
|
115
|
+
assertInside(root, p)
|
|
116
|
+
await fsAccess(p, constants.R_OK | constants.W_OK)
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
}) as ToolDefinition,
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (wanted.has("bash")) {
|
|
124
|
+
tools.push(
|
|
125
|
+
createBashToolDefinition(root, {
|
|
126
|
+
// Best-effort: always run from the workspace root. Not a hard jail.
|
|
127
|
+
spawnHook: (ctx) => ({ ...ctx, cwd: root }),
|
|
128
|
+
}) as ToolDefinition,
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Read-only discovery tools: rooted at the workspace cwd (default operations).
|
|
133
|
+
if (wanted.has("grep")) tools.push(createGrepToolDefinition(root) as ToolDefinition)
|
|
134
|
+
if (wanted.has("find")) tools.push(createFindToolDefinition(root) as ToolDefinition)
|
|
135
|
+
if (wanted.has("ls")) tools.push(createLsToolDefinition(root) as ToolDefinition)
|
|
136
|
+
|
|
137
|
+
// ask_user: available to all agents — no sandboxing needed, it's a communication tool.
|
|
138
|
+
tools.push(createAskUserToolDefinition() as ToolDefinition)
|
|
139
|
+
|
|
140
|
+
return tools
|
|
141
|
+
}
|