MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / build

Function build

src/tool/workspace-path.ts:30–71  ·  view source on GitHub ↗
(ctx: WorkspaceToolContext)

Source from the content-addressed store, hash-verified

28export const workspacePathFactory: WorkspaceToolFactory = {
29 name: 'workspace_path',
30 build(ctx: WorkspaceToolContext) {
31 return tool({
32 description: [
33 "Resolve a workspace's absolute directory by its id — the addressing step for reading a peer workspace's files.",
34 '',
35 "An inbox entry from another workspace (see inbox_read) carries its `workspaceId`; pass that here to get the peer's absolute path, then READ `<path>/<the entry's doc path>` with your normal file tools. Reading a peer is fine.",
36 '',
37 "EDITING a peer is different: only do it in an interactive session where a person is present to approve reaching outside your own workspace. An autonomous / headless run must read peers but write ONLY its own workspace. If you do edit a peer (with approval), commit the change in that repo with a clear message — it's the owner's record, and the commit is how they review or revert it. Never edit-and-walk-away.",
38 '',
39 "For your OWN entries (inbox_read `mine: true`) you don't need this — those doc paths are already relative to your current working directory.",
40 ].join('\n'),
41 inputSchema: z.object({
42 id: z
43 .string()
44 .min(1)
45 .describe("The workspace id to locate (e.g. the `workspaceId` from an inbox_read entry)."),
46 }),
47 execute: async ({ id }) => {
48 try {
49 const resolve = ctx.resolveWorkspace
50 if (!resolve) {
51 return { ok: false as const, error: 'workspace resolution is unavailable in this context' }
52 }
53 const meta = resolve(id)
54 if (!meta) {
55 return { ok: false as const, error: `unknown workspace: ${id}` }
56 }
57 return {
58 ok: true as const,
59 id: meta.id,
60 tag: meta.tag,
61 path: meta.dir,
62 }
63 } catch (err) {
64 return {
65 ok: false as const,
66 error: err instanceof Error ? err.message : String(err),
67 }
68 }
69 },
70 })
71 },
72}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected