@taco-ai/sidecar 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/LICENSE +21 -0
- package/README.md +103 -0
- package/bin/taco-sidecar.cjs +114 -0
- package/lib/sidecar.mjs +1075 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NiumAgents
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# `@taco-ai/sidecar`
|
|
2
|
+
|
|
3
|
+
The Taco sidecar: an NDJSON-over-stdio JSON-RPC server wrapping Pi's
|
|
4
|
+
`@earendil-works/pi-agent-core` AgentHarness. One process hosts many
|
|
5
|
+
workspaces and many sessions; the desktop / CLI / Python / TUI
|
|
6
|
+
clients all drive it via the same protocol.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @taco-ai/sidecar
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or run from source (no install needed):
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm dev:sidecar # tsx watch packages/sidecar/src/index.ts
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## What it does
|
|
21
|
+
|
|
22
|
+
- **Multi-workspace routing.** Workspace is the primary key
|
|
23
|
+
(`cwd` for IDE/CLI workspaces, `im://<channelId>/<peerId>/<chatId>`
|
|
24
|
+
for IM). Each workspace has its own `WorkspaceRuntime`, and every
|
|
25
|
+
session inside it owns an independent `AgentHarness` — so sessions
|
|
26
|
+
and workspaces both run fully in parallel. Only concurrent turns on
|
|
27
|
+
the *same* session are serialized, via a `(workspace, sessionId)`
|
|
28
|
+
gate that returns `session_busy`.
|
|
29
|
+
- **Dynamic tool loading.** Tools are split into `loading: "always"`
|
|
30
|
+
(resident from session start) and `loading: "deferred"`
|
|
31
|
+
(loaded on demand via the `addTools` tool). MCP servers,
|
|
32
|
+
skill subagents, and other sources populate the candidate
|
|
33
|
+
pool via `DeferredToolRegistry`.
|
|
34
|
+
- **IM channels.** A pluggable Channel SDK (`Channel` +
|
|
35
|
+
`ChannelHandle`); channels are added as opt-in dependencies.
|
|
36
|
+
- **Permission broker.** 5-level risk classification (readOnly /
|
|
37
|
+
workspaceWrite / externalSideEffect / destructive /
|
|
38
|
+
privilegeEscape) with rule-based ask / allow / deny and
|
|
39
|
+
per-(channel, chat) IM policy overrides.
|
|
40
|
+
- **Subagents.** `agent` / `agentContinue` tools spawn a child
|
|
41
|
+
session with a per-agent whitelist and a depth-based recursion
|
|
42
|
+
guard.
|
|
43
|
+
- **Checkpoints.** Turn-scoped pre-write file snapshots; restore
|
|
44
|
+
is exposed as `checkpoints.restore` but never as a model tool
|
|
45
|
+
(destructive, human-driven only).
|
|
46
|
+
- **Memory / tasks / plan / skills / agents** — see
|
|
47
|
+
`packages/sidecar/src/{memory,tasks,plan,skills,agents}/`.
|
|
48
|
+
|
|
49
|
+
## Architecture
|
|
50
|
+
|
|
51
|
+
See [`docs/02-architecture.md`](../../docs/02-architecture.md) for
|
|
52
|
+
the full three-layer structure (`SidecarServer` →
|
|
53
|
+
`WorkspaceRuntime` → `AttachedSession`) and how push frames flow
|
|
54
|
+
back to the client.
|
|
55
|
+
|
|
56
|
+
## CLI
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
taco-sidecar [--default-model <id>] [--default-provider <id>] \
|
|
60
|
+
[--sessions-root <dir>] [--system-prompt <text>] \
|
|
61
|
+
[--thinking-level <off|minimal|low|medium|high|xhigh|max>] \
|
|
62
|
+
[--anthropic-api-key <key>] [--openai-api-key <key>]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
All flags have `TACO_*` env equivalents and `taco.json` config
|
|
66
|
+
overrides (see [`docs/03-config.md`](../../docs/03-config.md)).
|
|
67
|
+
|
|
68
|
+
## Configuration loading
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
env (TACO_*, ANTHROPIC_API_KEY, …)
|
|
72
|
+
→ $TACO_HOME/taco.json
|
|
73
|
+
→ CLI args
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`$TACO_HOME` defaults to `~/.taco` (override with `TACO_HOME`).
|
|
77
|
+
Secret-bearing fields (`apiKeys`, `mcpServers[i].{env,headers,…}`)
|
|
78
|
+
are stripped before they cross the IPC boundary — see
|
|
79
|
+
`TacoGlobalConfigView` in `@taco-ai/protocol`.
|
|
80
|
+
|
|
81
|
+
## Optional dependencies
|
|
82
|
+
|
|
83
|
+
Channel SDKs are declared as `optionalDependencies` so installs without
|
|
84
|
+
them still succeed. `channels.list` advertises each channel type
|
|
85
|
+
regardless of whether the SDK is installed, but `channels.bind`
|
|
86
|
+
returns the channel's `<channel>_sdk_missing` error so the desktop
|
|
87
|
+
can offer a one-click install.
|
|
88
|
+
|
|
89
|
+
## Build
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pnpm -F @taco-ai/sidecar build # bundle via esbuild → dist/
|
|
93
|
+
pnpm -F @taco-ai/sidecar package:runtime --target <triple>
|
|
94
|
+
# produce release-stage binary per triple
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Release builds are consumed by `@taco-ai/desktop`'s Tauri bundle
|
|
98
|
+
(`externalBin` + `resources/sidecar/`) and by npm-packaged
|
|
99
|
+
installs that bring their own `node`.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT — see [LICENSE](LICENSE) (symlink to the root).
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* taco-sidecar — Node shim that locates the bundled platform binary and spawns it.
|
|
4
|
+
*
|
|
5
|
+
* Resolution strategy:
|
|
6
|
+
* 1. Resolve the platform-specific optional dep via `require.resolve`.
|
|
7
|
+
* 2. Read its `manifest.json` to locate the Node binary and bundle.
|
|
8
|
+
* 3. Spawn that binary with the bundle as argument.
|
|
9
|
+
* 4. On failure, exit with a clear message (not a cryptic ENOENT).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const path = require("node:path");
|
|
13
|
+
const { spawn } = require("node:child_process");
|
|
14
|
+
const fs = require("node:fs");
|
|
15
|
+
|
|
16
|
+
// Detect the platform key from the optional dep names npm installs.
|
|
17
|
+
// Keep in sync with the six PLATFORMS in stagePlatformPackages.mjs.
|
|
18
|
+
const PLATFORM_KEYS = [
|
|
19
|
+
"darwin-arm64",
|
|
20
|
+
"darwin-x64",
|
|
21
|
+
"linux-x64",
|
|
22
|
+
"linux-arm64",
|
|
23
|
+
"win32-x64",
|
|
24
|
+
"win32-arm64",
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
function resolvePlatformPkg() {
|
|
28
|
+
for (const key of PLATFORM_KEYS) {
|
|
29
|
+
const pkgName = `@taco-ai/sidecar-${key}`;
|
|
30
|
+
try {
|
|
31
|
+
// require.resolve walks up node_modules/ until it finds the package.
|
|
32
|
+
// This works whether optionalDeps are hoisted or nested.
|
|
33
|
+
return { key, pkgJson: require.resolve(`${pkgName}/package.json`) };
|
|
34
|
+
} catch {
|
|
35
|
+
// not installed / not this platform — try next
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function resolveFromManifest(pkgJsonPath) {
|
|
42
|
+
const pkgDir = path.dirname(pkgJsonPath);
|
|
43
|
+
const manifestPath = path.join(pkgDir, "manifest.json");
|
|
44
|
+
if (!fs.existsSync(manifestPath)) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
"manifest.json not found at " +
|
|
47
|
+
manifestPath +
|
|
48
|
+
" — the @taco-ai/sidecar platform package may be corrupt.",
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
52
|
+
return {
|
|
53
|
+
nodeBin: path.join(
|
|
54
|
+
pkgDir,
|
|
55
|
+
"bin",
|
|
56
|
+
manifest.target.endsWith("-pc-windows-msvc")
|
|
57
|
+
? "taco-sidecar-node.exe"
|
|
58
|
+
: "taco-sidecar-node",
|
|
59
|
+
),
|
|
60
|
+
bundle: path.join(pkgDir, "lib", "index.mjs"),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function main() {
|
|
65
|
+
const pkg = resolvePlatformPkg();
|
|
66
|
+
if (!pkg) {
|
|
67
|
+
console.error(
|
|
68
|
+
"[taco-sidecar] ERROR: no platform-specific binary found.\n" +
|
|
69
|
+
" Make sure you ran `npm install` on a supported platform:\n" +
|
|
70
|
+
" " +
|
|
71
|
+
PLATFORM_KEYS.map((k) => `@taco-ai/sidecar-${k}`).join(", ") +
|
|
72
|
+
"\n" +
|
|
73
|
+
" If you believe this is a bug, please report it with your platform output:\n" +
|
|
74
|
+
" " +
|
|
75
|
+
process.platform +
|
|
76
|
+
"/" +
|
|
77
|
+
process.arch,
|
|
78
|
+
);
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const { nodeBin, bundle } = resolveFromManifest(pkg.pkgJson);
|
|
83
|
+
if (!fs.existsSync(nodeBin)) {
|
|
84
|
+
console.error(
|
|
85
|
+
`[taco-sidecar] ERROR: Node binary not found at ${nodeBin}. ` +
|
|
86
|
+
`The @taco-ai/sidecar-${pkg.key} package may be corrupt.`,
|
|
87
|
+
);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Pass through all arguments after the script name to the bundle.
|
|
92
|
+
const child = spawn(nodeBin, [bundle, ...process.argv.slice(2)], {
|
|
93
|
+
// inherit stdin/stdout/stderr so the sidecar NDJSON stream passes through
|
|
94
|
+
// and signals (SIGINT etc.) reach the child.
|
|
95
|
+
stdio: "inherit",
|
|
96
|
+
env: {
|
|
97
|
+
...process.env,
|
|
98
|
+
// Let the bundle know where its resources (agents/, skills/) live.
|
|
99
|
+
TACO_SIDECAR_RESOURCES: path.dirname(bundle),
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
child.on("exit", (code, sig) => {
|
|
104
|
+
// POSIX: `sig` is the terminating signal name ("SIGKILL", "SIGTERM", …);
|
|
105
|
+
// map SIGKILL → 137 so callers see the conventional OOM-killer code.
|
|
106
|
+
// Windows: Node never delivers POSIX-style signal names — `sig` is
|
|
107
|
+
// usually `null`, occasionally a numeric Windows exception code.
|
|
108
|
+
// The 137→1 fallback only fires on Unix; Windows always takes the
|
|
109
|
+
// `code ?? 1` branch and surfaces the child's own exit code.
|
|
110
|
+
process.exitCode = code ?? (sig === "SIGKILL" ? 137 : 1);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
main();
|