@ignitionai/cogitator 0.4.0 → 0.5.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/README.md +30 -8
- package/dist/extensions/index.js +1 -1
- package/dist/src/classic-configuration.js +153 -0
- package/dist/src/conversations.js +9 -7
- package/dist/src/db.js +52 -3
- package/dist/src/default-agent.js +1 -1
- package/dist/src/durable/admission.js +131 -0
- package/dist/src/durable/approvals.js +171 -0
- package/dist/src/durable/compatibility.js +59 -0
- package/dist/src/durable/effect-gateway.js +68 -0
- package/dist/src/durable/lease.js +48 -0
- package/dist/src/durable/manager.js +167 -0
- package/dist/src/durable/mission-runtime.js +460 -0
- package/dist/src/durable/profile.js +79 -0
- package/dist/src/durable/workers.js +42 -0
- package/dist/src/execution/admission.js +45 -0
- package/dist/src/execution/confinement.js +108 -0
- package/dist/src/execution/container.js +102 -0
- package/dist/src/execution/egress.js +69 -0
- package/dist/src/groups.js +71 -0
- package/dist/src/pool.js +193 -72
- package/dist/src/provider-login.js +115 -0
- package/dist/src/registry.js +72 -14
- package/dist/src/runtime.js +92 -0
- package/dist/src/schemas.js +45 -0
- package/dist/src/server.js +423 -23
- package/dist/src/spawner.js +34 -12
- package/dist/src/workspace-files.js +6 -5
- package/dist/src/workspaces.js +19 -6
- package/package.json +4 -1
- package/web/dist/assets/index-C3tRuOTh.js +83 -0
- package/web/dist/assets/index-DMQqB0r1.css +1 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-D3Q54zLM.js +0 -83
- package/web/dist/assets/index-Kj5NVQYi.css +0 -1
package/dist/src/spawner.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { checkRequestAuthorization } from "./request-authorization.js";
|
|
2
|
+
import { reconcileConfiguration } from "./classic-configuration.js";
|
|
1
3
|
import { mkdirSync } from "node:fs";
|
|
2
4
|
import { homedir } from "node:os";
|
|
3
5
|
import { join } from "node:path";
|
|
4
|
-
import { setConversationSession } from "./conversations.js";
|
|
6
|
+
import { getConversation, setConversationSession } from "./conversations.js";
|
|
5
7
|
import { UI_INSTRUCTIONS, UI_PRESENTATION_POLICY } from "./generative-ui.js";
|
|
6
8
|
import { MCP_ENV_VAR, encodeMcpEnv } from "./mcp-env.js";
|
|
7
9
|
import { buildArgs } from "./spawn.js";
|
|
@@ -15,18 +17,38 @@ export function makeSpawner(opts) {
|
|
|
15
17
|
return {
|
|
16
18
|
tmpDir,
|
|
17
19
|
async ensure(conv) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
return pool.serial(conv.id, async () => {
|
|
21
|
+
const current = getConversation(db, conv.id);
|
|
22
|
+
if (!current)
|
|
23
|
+
throw new Error("conversation not found");
|
|
24
|
+
conv = current;
|
|
25
|
+
// I3 (amendé Durable) : le pool classic ne spawn JAMAIS pour une conversation
|
|
26
|
+
// durable — la runtime Durable du contrôleur est le seul mécanisme (point
|
|
27
|
+
// de composition src/runtime.ts). Un spawn ici serait un processus non géré.
|
|
28
|
+
if (conv.runtime_kind === "durable") {
|
|
29
|
+
throw new Error("conversation durable : aucun processus pi classic (runtime.ts)");
|
|
30
|
+
}
|
|
31
|
+
const spawn = JSON.parse(conv.spawn_args || "{}");
|
|
32
|
+
const mcpEnv = encodeMcpEnv(spawn.mcpServers ?? []);
|
|
33
|
+
const result = await pool.ensure(conv.id, {
|
|
34
|
+
cwd: conv.workspace_dir ?? homedir(),
|
|
35
|
+
// Host presentation capability: also available to legacy sessions, without rewriting their snapshot.
|
|
36
|
+
args: buildArgs({ ...spawn, uiInstructions: `${spawn.uiInstructions ?? UI_INSTRUCTIONS}\n\n${UI_PRESENTATION_POLICY}\n\n${ENVIRONMENT_NOTICE}` }, tmpDir, conv.id),
|
|
37
|
+
resumeSessionFile: conv.session_file,
|
|
38
|
+
initialize: client => reconcileConfiguration(db, pool, conv.id, client),
|
|
39
|
+
env: mcpEnv ? { [MCP_ENV_VAR]: mcpEnv } : undefined,
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
checkRequestAuthorization();
|
|
43
|
+
if (result.sessionFile)
|
|
44
|
+
setConversationSession(db, conv.id, result.sessionFile);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
await pool.evict(conv.id);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
26
51
|
});
|
|
27
|
-
if (result.sessionFile)
|
|
28
|
-
setConversationSession(db, conv.id, result.sessionFile);
|
|
29
|
-
return result;
|
|
30
52
|
},
|
|
31
53
|
};
|
|
32
54
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
-
import { extname, basename, join
|
|
2
|
+
import { extname, basename, join } from "node:path";
|
|
3
|
+
import { resolveConfined } from "./execution/confinement.js";
|
|
3
4
|
const SKIP_DIRS = new Set(["node_modules", ".git", "dist", "build", ".next", ".venv", "__pycache__", "coverage", ".turbo"]);
|
|
4
5
|
const MAX_DEPTH = 5;
|
|
5
6
|
const MAX_NODES = 500;
|
|
@@ -56,11 +57,11 @@ const TEXT_EXT = new Set([
|
|
|
56
57
|
* sous la racine du workspace (anti-traversal), taille plafonnée, extensions binaires refusées.
|
|
57
58
|
*/
|
|
58
59
|
export function readWorkspaceFile(rootDir, requested) {
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
60
|
+
// Anti-traversal lexical + rejet des échappées par symlink (résolution realpath, Plan 0002 §4).
|
|
61
|
+
const confined = resolveConfined(rootDir, requested);
|
|
62
|
+
if ("error" in confined)
|
|
62
63
|
return { error: "chemin hors du workspace" };
|
|
63
|
-
|
|
64
|
+
const target = confined.path;
|
|
64
65
|
if (!existsSync(target))
|
|
65
66
|
return { error: `fichier introuvable: ${requested}` };
|
|
66
67
|
let stat;
|
package/dist/src/workspaces.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { existsSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
3
3
|
import { basename, join } from "node:path";
|
|
4
|
+
import { enrollWorkspaceDir } from "./execution/confinement.js";
|
|
4
5
|
export function listWorkspaces(db) {
|
|
5
6
|
return db
|
|
6
7
|
.prepare(`SELECT w.*, (SELECT COUNT(*) FROM conversation c WHERE c.workspace_id = w.id) AS conversation_count
|
|
@@ -19,18 +20,30 @@ export function getWorkspaceByDir(db, dir) {
|
|
|
19
20
|
function agentExists(db, id) {
|
|
20
21
|
return Boolean(db.prepare("SELECT 1 FROM agent_preset WHERE id = ?").get(id));
|
|
21
22
|
}
|
|
22
|
-
/**
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Crée un workspace. Invariant (domain model) : le dossier doit exister ; dir unique.
|
|
25
|
+
* `policy` (mode distant) : l'enrôlement est restreint aux racines enrôlées et rejette
|
|
26
|
+
* les échappées par symlink (Plan 0002 §4) ; absent = comportement local historique.
|
|
27
|
+
*/
|
|
28
|
+
export function createWorkspace(db, input, policy) {
|
|
24
29
|
if (!existsSync(input.dir))
|
|
25
30
|
return { error: `dossier introuvable: ${input.dir}` };
|
|
26
31
|
if (!statSync(input.dir).isDirectory())
|
|
27
32
|
return { error: `n'est pas un dossier: ${input.dir}` };
|
|
28
33
|
let dir;
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
if (policy) {
|
|
35
|
+
const enrolled = enrollWorkspaceDir(policy, input.dir);
|
|
36
|
+
if ("error" in enrolled)
|
|
37
|
+
return { error: enrolled.error };
|
|
38
|
+
dir = enrolled.dir;
|
|
31
39
|
}
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
else {
|
|
41
|
+
try {
|
|
42
|
+
dir = realpathSync(input.dir); // canonicalise (symlinks, trailing /)
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return { error: `dossier illisible: ${input.dir}` };
|
|
46
|
+
}
|
|
34
47
|
}
|
|
35
48
|
if (getWorkspaceByDir(db, dir))
|
|
36
49
|
return { error: `workspace déjà enregistré pour ${dir}` };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ignitionai/cogitator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A web control panel for pi: composable agents, workspaces, interactive conversations, and scheduled tasks. A pi package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -52,6 +52,9 @@
|
|
|
52
52
|
"@earendil-works/pi-coding-agent": "*"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
+
"@earendil-works/chord": "1.1.0",
|
|
56
|
+
"@earendil-works/pi-ai": "1.1.0",
|
|
57
|
+
"@earendil-works/pi-durable": "1.1.0",
|
|
55
58
|
"@fontsource/inter": "^5.3.0",
|
|
56
59
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
57
60
|
"better-auth": "1.7.7",
|