flint-agent 1.14.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 +108 -0
- package/CHANGELOG.md +55 -0
- package/FEATURES.md +298 -0
- package/LICENSE +21 -0
- package/README.md +435 -0
- package/bin/flint.js +47 -0
- package/config/classifier-prompt.md +218 -0
- package/config/models-curated.json +4 -0
- package/config/providers.json +74 -0
- package/package.json +92 -0
- package/patches/ink+6.8.0.patch +78 -0
- package/profiles/desktop.md +65 -0
- package/profiles/generic.md +20 -0
- package/profiles/marketer.md +20 -0
- package/profiles/profiles.json +34 -0
- package/profiles/ux-reviewer.md +25 -0
- package/src/agent/agent.js +1743 -0
- package/src/agent/auto.js +346 -0
- package/src/agent/backoff.js +143 -0
- package/src/agent/compression.js +310 -0
- package/src/agent/content-resolver.js +180 -0
- package/src/agent/flow-controller.js +309 -0
- package/src/agent/intent-manifest.js +231 -0
- package/src/agent/intent-timeout.js +46 -0
- package/src/agent/intent.js +633 -0
- package/src/agent/knowledge.js +114 -0
- package/src/agent/learning.js +180 -0
- package/src/agent/modes.js +187 -0
- package/src/agent/outcome-ask.js +91 -0
- package/src/agent/project-context.js +76 -0
- package/src/agent/prompt-budget.js +117 -0
- package/src/agent/reflection-extractor.js +140 -0
- package/src/agent/steering.js +86 -0
- package/src/agent/supervisor.js +430 -0
- package/src/agent/swap.js +443 -0
- package/src/agent/system-prompt.js +446 -0
- package/src/agent/time-stamp.js +48 -0
- package/src/agent/tool-guard.js +201 -0
- package/src/agent/toolcall-text.js +162 -0
- package/src/agent/usage.js +297 -0
- package/src/agent/vision.js +94 -0
- package/src/agent/watchdog.js +139 -0
- package/src/agent/workspace-changes.js +177 -0
- package/src/api/address.js +14 -0
- package/src/api/client.js +280 -0
- package/src/api/server.js +535 -0
- package/src/api/stream-pipe.js +113 -0
- package/src/app-state.js +39 -0
- package/src/bootstrap.js +501 -0
- package/src/bus/drain-loop.js +497 -0
- package/src/bus/index.js +270 -0
- package/src/bus/plugins.js +65 -0
- package/src/child-idle.js +14 -0
- package/src/cli.js +118 -0
- package/src/commands/commands.js +1297 -0
- package/src/commands/registry.js +132 -0
- package/src/components/App.js +491 -0
- package/src/components/CarefulMenu.js +145 -0
- package/src/components/HistoryWriter.js +86 -0
- package/src/components/LineInput.js +69 -0
- package/src/components/LiveZone.js +294 -0
- package/src/components/OverlayMenu.js +179 -0
- package/src/components/SystemPanel.js +156 -0
- package/src/components/Table.js +54 -0
- package/src/config.js +249 -0
- package/src/free-models.js +230 -0
- package/src/index.js +1111 -0
- package/src/input-handler.js +13 -0
- package/src/input-text.js +123 -0
- package/src/launcher.js +129 -0
- package/src/logging/api-log.js +95 -0
- package/src/logging/chat-log-follower.js +113 -0
- package/src/logging/chat-log.js +15 -0
- package/src/logging/log-collector.js +182 -0
- package/src/logging/logger.js +112 -0
- package/src/logging/tool-log.js +20 -0
- package/src/mcp-client.js +314 -0
- package/src/memory/conversation-digest.js +113 -0
- package/src/memory/extract-facts.js +98 -0
- package/src/memory/facts.js +181 -0
- package/src/memory/inbox.js +63 -0
- package/src/memory/markdown.js +38 -0
- package/src/memory/patterns.js +185 -0
- package/src/memory/project.js +66 -0
- package/src/memory/reflections.js +74 -0
- package/src/memory/retrieval.js +84 -0
- package/src/memory/rules.js +105 -0
- package/src/memory/session-facts.js +125 -0
- package/src/memory/skills.js +191 -0
- package/src/memory/sqlite-store.js +653 -0
- package/src/memory/store.js +208 -0
- package/src/memory/tools.js +196 -0
- package/src/memory/user-model.js +86 -0
- package/src/message-handler.js +775 -0
- package/src/model-check.js +218 -0
- package/src/plugins/loader.js +120 -0
- package/src/plugins/manager.js +88 -0
- package/src/production-env.js +22 -0
- package/src/profiles.js +42 -0
- package/src/providers/adapters/anthropic.js +270 -0
- package/src/providers/adapters/openai.js +120 -0
- package/src/providers/keys-dpapi.js +41 -0
- package/src/providers/keys-fallback.js +31 -0
- package/src/providers/keys.js +132 -0
- package/src/providers/models.js +154 -0
- package/src/providers/registry.js +56 -0
- package/src/providers/state.js +56 -0
- package/src/registry.js +96 -0
- package/src/restart.js +29 -0
- package/src/sandbox/backend.js +130 -0
- package/src/security/api-auth.js +132 -0
- package/src/security/audit.js +98 -0
- package/src/security/child-policy.js +41 -0
- package/src/security/command-guard.js +173 -0
- package/src/security/content-fence.js +250 -0
- package/src/security/content-validator.js +132 -0
- package/src/security/index.js +143 -0
- package/src/security/network-guard.js +126 -0
- package/src/security/pairing.js +180 -0
- package/src/security/path-guard.js +140 -0
- package/src/security/persona-guard.js +67 -0
- package/src/security/policies.js +452 -0
- package/src/security/safety-constants.js +34 -0
- package/src/security/watchdog.js +107 -0
- package/src/sessions.js +130 -0
- package/src/spend.js +97 -0
- package/src/startup-watchdog.js +59 -0
- package/src/stdio/args.js +71 -0
- package/src/stdio/guard.js +59 -0
- package/src/stdio/protocol.js +167 -0
- package/src/stdio/run.js +106 -0
- package/src/stdio/session.js +180 -0
- package/src/store/agent-slice.js +306 -0
- package/src/store/dataset-slice.js +73 -0
- package/src/store/index.js +22 -0
- package/src/store/process-slice.js +135 -0
- package/src/store/session-slice.js +191 -0
- package/src/store/ui-slice.js +119 -0
- package/src/tasks/db.js +184 -0
- package/src/tasks/queries.js +589 -0
- package/src/tools/agent-tools.js +473 -0
- package/src/tools/checkpoint.js +152 -0
- package/src/tools/command-approvals.js +180 -0
- package/src/tools/dataset.js +50 -0
- package/src/tools/filesystem.js +682 -0
- package/src/tools/inbox-tools.js +48 -0
- package/src/tools/mesh.js +135 -0
- package/src/tools/own-env.js +136 -0
- package/src/tools/permissions.js +681 -0
- package/src/tools/plugin-tools.js +123 -0
- package/src/tools/process-tools.js +595 -0
- package/src/tools/registry.js +307 -0
- package/src/tools/swap-tools.js +72 -0
- package/src/tools/system.js +662 -0
- package/src/tools/tasks.js +532 -0
- package/src/tools/tool-search.js +171 -0
- package/src/ui/header.js +140 -0
- package/src/ui/input-cursor.js +23 -0
- package/src/ui/last-line.js +25 -0
- package/src/ui/line-edit.js +135 -0
- package/src/ui/output.js +399 -0
- package/src/ui/paste-tokens.js +131 -0
- package/src/ui/prompt-attention.js +134 -0
- package/src/ui/render-options.js +13 -0
- package/src/ui/replay.js +94 -0
- package/src/ui/splash.js +49 -0
- package/src/ui/status-level.js +36 -0
- package/src/ui/tool-ledger.js +203 -0
- package/src/ui/window-title.js +150 -0
- package/src/update.js +205 -0
- package/system.md +63 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// install_plugin and reload_plugins: the agent extends itself from the
|
|
2
|
+
// conversation, and what it adds is usable in the same turn.
|
|
3
|
+
//
|
|
4
|
+
// WHY: plugins were read once at boot, and /install ended with "Restart to
|
|
5
|
+
// activate". So when a task needed a capability Flint lacked, the model could
|
|
6
|
+
// not add one: it could write a plugin or name a package, but the tool would
|
|
7
|
+
// only exist after a restart nobody was going to do mid-task. In the bench it
|
|
8
|
+
// instead spent up to 24 calls improvising around the gap.
|
|
9
|
+
//
|
|
10
|
+
// A plugin is code with the agent's own rights (files, commands, network).
|
|
11
|
+
// Both tools are "confirm" in the default permissions, and a plugin may not
|
|
12
|
+
// take a tool name that is already registered (see registerPlugin).
|
|
13
|
+
|
|
14
|
+
import { existsSync, rmSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { loadPlugin, listInstalledPlugins, getPluginsDir } from "../plugins/loader.js";
|
|
17
|
+
import { installPlugin } from "../plugins/manager.js";
|
|
18
|
+
import { registerPlugin, unregisterPlugin, getLoadedPlugins } from "./registry.js";
|
|
19
|
+
import { markLoaded } from "./tool-search.js";
|
|
20
|
+
|
|
21
|
+
// What a plugin's init() receives; bootstrap fills it with config and store.
|
|
22
|
+
let pluginContext = {};
|
|
23
|
+
export function setPluginContext(ctx) {
|
|
24
|
+
pluginContext = ctx || {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* (Re)load one plugin folder: take out what it registered before, import it
|
|
29
|
+
* fresh, init, register, and put its tools in hand.
|
|
30
|
+
* @returns {Promise<{dir, name?, tools?: string[], error?: string}>}
|
|
31
|
+
*/
|
|
32
|
+
export async function activatePlugin(dir) {
|
|
33
|
+
const old = unregisterPlugin(dir);
|
|
34
|
+
if (old?.destroy) {
|
|
35
|
+
try { await old.destroy(); } catch {}
|
|
36
|
+
}
|
|
37
|
+
const p = await loadPlugin(dir, { fresh: true });
|
|
38
|
+
if (!p) return { dir, error: "no index.js" };
|
|
39
|
+
if (p.error) return { dir, name: p.name, error: p.error };
|
|
40
|
+
try {
|
|
41
|
+
if (p.init) await p.init(pluginContext);
|
|
42
|
+
registerPlugin(p);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
return { dir, name: p.name, error: err.message };
|
|
45
|
+
}
|
|
46
|
+
const tools = (p.tools || []).map((t) => t.function?.name).filter(Boolean);
|
|
47
|
+
markLoaded(tools);
|
|
48
|
+
return { dir, name: p.name, tools };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function describe(results) {
|
|
52
|
+
const lines = results.map((r) =>
|
|
53
|
+
r.error
|
|
54
|
+
? `- ${r.name || r.dir}: NOT loaded: ${r.error}`
|
|
55
|
+
: `- ${r.name}: ${r.tools.length ? `tools available now: ${r.tools.join(", ")}` : "loaded, no tools"}`);
|
|
56
|
+
return lines.join("\n");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const tools = [
|
|
60
|
+
{
|
|
61
|
+
type: "function",
|
|
62
|
+
function: {
|
|
63
|
+
name: "install_plugin",
|
|
64
|
+
description:
|
|
65
|
+
"Install a Flint plugin and load it at once, so its tools can be called in this same turn. " +
|
|
66
|
+
"`source` is a local folder holding the plugin's index.js, or an npm package name " +
|
|
67
|
+
"(installed as flint-plugin-<name>). A plugin runs with your full rights.",
|
|
68
|
+
parameters: {
|
|
69
|
+
type: "object",
|
|
70
|
+
properties: {
|
|
71
|
+
source: { type: "string", description: "Local plugin folder, or npm package name" },
|
|
72
|
+
},
|
|
73
|
+
required: ["source"],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: "function",
|
|
79
|
+
function: {
|
|
80
|
+
name: "reload_plugins",
|
|
81
|
+
description:
|
|
82
|
+
"Re-read the plugins folder and load every plugin in it fresh, including ones you just wrote or changed. " +
|
|
83
|
+
"Their tools are callable in this same turn. A plugin is a folder <plugins dir>/<name>/ with an index.js " +
|
|
84
|
+
"whose default export is { name, tools: [OpenAI-style function definitions], handlers: { toolName: async (args) => string } }. " +
|
|
85
|
+
"The result names the plugins folder.",
|
|
86
|
+
parameters: { type: "object", properties: {} },
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
export const handlers = {
|
|
92
|
+
async install_plugin({ source }) {
|
|
93
|
+
const res = await installPlugin(String(source || "").trim());
|
|
94
|
+
if (!res.ok) return `Error: ${res.error}`;
|
|
95
|
+
const r = await activatePlugin(res.path);
|
|
96
|
+
if (r.error) {
|
|
97
|
+
// Installed but unusable: taken out again, so the next boot does not
|
|
98
|
+
// trip over it and the folder does not pretend to be a working plugin.
|
|
99
|
+
try { rmSync(res.path, { recursive: true, force: true }); } catch {}
|
|
100
|
+
return `Error: installed ${res.name} but could not load it, removed again: ${r.error}`;
|
|
101
|
+
}
|
|
102
|
+
return `Installed and loaded:\n${describe([r])}`;
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
async reload_plugins() {
|
|
106
|
+
const root = getPluginsDir();
|
|
107
|
+
const dirs = listInstalledPlugins().map((d) => join(root, d));
|
|
108
|
+
// A plugin whose folder is gone is taken out, not left registered.
|
|
109
|
+
for (const p of getLoadedPlugins().slice()) {
|
|
110
|
+
if (p.dir && !dirs.includes(p.dir) && !existsSync(p.dir)) {
|
|
111
|
+
const old = unregisterPlugin(p.dir);
|
|
112
|
+
if (old?.destroy) { try { await old.destroy(); } catch {} }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const results = [];
|
|
116
|
+
for (const dir of dirs) {
|
|
117
|
+
if (!existsSync(join(dir, "index.js"))) continue;
|
|
118
|
+
results.push(await activatePlugin(dir));
|
|
119
|
+
}
|
|
120
|
+
if (!results.length) return `No plugins in ${root}.`;
|
|
121
|
+
return `Plugins folder: ${root}\n${describe(results)}`;
|
|
122
|
+
},
|
|
123
|
+
};
|