instar 0.9.21 → 0.9.23
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/dist/cli.js +51 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +209 -14
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/knowledge.d.ts +25 -0
- package/dist/commands/knowledge.d.ts.map +1 -0
- package/dist/commands/knowledge.js +127 -0
- package/dist/commands/knowledge.js.map +1 -0
- package/dist/commands/nuke.d.ts +22 -0
- package/dist/commands/nuke.d.ts.map +1 -0
- package/dist/commands/nuke.js +175 -0
- package/dist/commands/nuke.js.map +1 -0
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +32 -24
- package/dist/commands/server.js.map +1 -1
- package/dist/core/Config.d.ts +2 -0
- package/dist/core/Config.d.ts.map +1 -1
- package/dist/core/Config.js +42 -0
- package/dist/core/Config.js.map +1 -1
- package/dist/core/GitSync.d.ts +6 -0
- package/dist/core/GitSync.d.ts.map +1 -1
- package/dist/core/GitSync.js +11 -0
- package/dist/core/GitSync.js.map +1 -1
- package/dist/core/PostUpdateMigrator.d.ts +6 -0
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +181 -5
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/types.d.ts +9 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/knowledge/KnowledgeManager.d.ts +85 -0
- package/dist/knowledge/KnowledgeManager.d.ts.map +1 -0
- package/dist/knowledge/KnowledgeManager.js +194 -0
- package/dist/knowledge/KnowledgeManager.js.map +1 -0
- package/dist/messaging/NotificationBatcher.d.ts +73 -0
- package/dist/messaging/NotificationBatcher.d.ts.map +1 -0
- package/dist/messaging/NotificationBatcher.js +193 -0
- package/dist/messaging/NotificationBatcher.js.map +1 -0
- package/dist/messaging/TelegramAdapter.d.ts +38 -1
- package/dist/messaging/TelegramAdapter.d.ts.map +1 -1
- package/dist/messaging/TelegramAdapter.js +157 -9
- package/dist/messaging/TelegramAdapter.js.map +1 -1
- package/dist/monitoring/SessionWatchdog.d.ts +15 -1
- package/dist/monitoring/SessionWatchdog.d.ts.map +1 -1
- package/dist/monitoring/SessionWatchdog.js +74 -3
- package/dist/monitoring/SessionWatchdog.js.map +1 -1
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +25 -0
- package/dist/scaffold/templates.js.map +1 -1
- package/package.json +2 -1
- package/src/templates/hooks/compaction-recovery.sh +165 -0
- package/src/templates/hooks/dangerous-command-guard.sh +100 -0
- package/src/templates/hooks/grounding-before-messaging.sh +52 -0
- package/src/templates/hooks/settings-template.json +63 -0
- package/src/templates/scripts/convergence-check.sh +90 -0
- package/src/templates/scripts/health-watchdog.sh +63 -0
- package/src/templates/scripts/telegram-reply.sh +67 -0
- package/upgrades/0.9.22.md +41 -0
- package/upgrades/0.9.23.md +37 -0
|
@@ -58,6 +58,10 @@ export class SessionWatchdog extends EventEmitter {
|
|
|
58
58
|
running = false;
|
|
59
59
|
stuckThresholdMs;
|
|
60
60
|
pollIntervalMs;
|
|
61
|
+
/** Intelligence provider — gates escalation entry with LLM command analysis */
|
|
62
|
+
intelligence = null;
|
|
63
|
+
/** Temporarily exempted commands (LLM confirmed as legitimate long-running) */
|
|
64
|
+
temporaryExclusions = new Set(); // PIDs
|
|
61
65
|
constructor(config, sessionManager, state) {
|
|
62
66
|
super();
|
|
63
67
|
this.config = config;
|
|
@@ -114,7 +118,7 @@ export class SessionWatchdog extends EventEmitter {
|
|
|
114
118
|
const sessions = this.sessionManager.listRunningSessions();
|
|
115
119
|
for (const session of sessions) {
|
|
116
120
|
try {
|
|
117
|
-
this.checkSession(session.tmuxSession);
|
|
121
|
+
await this.checkSession(session.tmuxSession);
|
|
118
122
|
}
|
|
119
123
|
catch (err) {
|
|
120
124
|
console.error(`[Watchdog] Error checking "${session.tmuxSession}":`, err);
|
|
@@ -125,7 +129,7 @@ export class SessionWatchdog extends EventEmitter {
|
|
|
125
129
|
this.running = false;
|
|
126
130
|
}
|
|
127
131
|
}
|
|
128
|
-
checkSession(tmuxSession) {
|
|
132
|
+
async checkSession(tmuxSession) {
|
|
129
133
|
const existing = this.escalationState.get(tmuxSession);
|
|
130
134
|
if (existing && existing.level > EscalationLevel.Monitoring) {
|
|
131
135
|
this.handleEscalation(tmuxSession, existing);
|
|
@@ -136,8 +140,17 @@ export class SessionWatchdog extends EventEmitter {
|
|
|
136
140
|
if (!claudePid)
|
|
137
141
|
return;
|
|
138
142
|
const children = this.getChildProcesses(claudePid);
|
|
139
|
-
const stuckChild = children.find(c => !this.isExcluded(c.command) &&
|
|
143
|
+
const stuckChild = children.find(c => !this.isExcluded(c.command) &&
|
|
144
|
+
!this.temporaryExclusions.has(c.pid) &&
|
|
145
|
+
c.elapsedMs > this.stuckThresholdMs);
|
|
140
146
|
if (stuckChild) {
|
|
147
|
+
// LLM gate: check if this command is legitimately long-running before escalating
|
|
148
|
+
const isStuck = await this.isCommandStuck(stuckChild.command, stuckChild.elapsedMs);
|
|
149
|
+
if (!isStuck) {
|
|
150
|
+
// LLM says legitimate — temporarily exclude this PID from future checks
|
|
151
|
+
this.temporaryExclusions.add(stuckChild.pid);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
141
154
|
const state = {
|
|
142
155
|
level: EscalationLevel.CtrlC,
|
|
143
156
|
levelEnteredAt: Date.now(),
|
|
@@ -154,6 +167,12 @@ export class SessionWatchdog extends EventEmitter {
|
|
|
154
167
|
else if (existing) {
|
|
155
168
|
this.escalationState.delete(tmuxSession);
|
|
156
169
|
}
|
|
170
|
+
// Clean up temporary exclusions for dead processes
|
|
171
|
+
for (const pid of this.temporaryExclusions) {
|
|
172
|
+
if (!this.isProcessAlive(pid)) {
|
|
173
|
+
this.temporaryExclusions.delete(pid);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
157
176
|
}
|
|
158
177
|
handleEscalation(tmuxSession, state) {
|
|
159
178
|
const now = Date.now();
|
|
@@ -205,6 +224,58 @@ export class SessionWatchdog extends EventEmitter {
|
|
|
205
224
|
break;
|
|
206
225
|
}
|
|
207
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* LLM gate: Before entering escalation, ask whether the command is
|
|
229
|
+
* legitimately long-running or actually stuck. This prevents the watchdog
|
|
230
|
+
* from killing legitimate builds, installs, or data processing.
|
|
231
|
+
*
|
|
232
|
+
* Returns true if the command appears stuck and should be escalated.
|
|
233
|
+
* Returns false if the LLM thinks it's a legitimate long-running task.
|
|
234
|
+
* If no LLM is available, returns true (fail-open — stuck commands need recovery).
|
|
235
|
+
*/
|
|
236
|
+
async isCommandStuck(command, elapsedMs) {
|
|
237
|
+
if (!this.intelligence)
|
|
238
|
+
return true; // No LLM → fail-open
|
|
239
|
+
const elapsedMin = Math.round(elapsedMs / 60000);
|
|
240
|
+
const prompt = [
|
|
241
|
+
'You are evaluating whether a running process is stuck or legitimately long-running.',
|
|
242
|
+
'',
|
|
243
|
+
`Command: ${command.slice(0, 200)}`,
|
|
244
|
+
`Running for: ${elapsedMin} minutes`,
|
|
245
|
+
'',
|
|
246
|
+
'Legitimate long-running commands include:',
|
|
247
|
+
'- Package installs (npm install, pip install, cargo build, etc.)',
|
|
248
|
+
'- Large builds (webpack, tsc with many files, docker build)',
|
|
249
|
+
'- Database migrations or data processing',
|
|
250
|
+
'- Test suites (pytest, vitest, jest with many tests)',
|
|
251
|
+
'- Network operations (curl large files, git clone large repos)',
|
|
252
|
+
'- Interactive processes (vim, less, ssh sessions)',
|
|
253
|
+
'',
|
|
254
|
+
'Likely stuck commands include:',
|
|
255
|
+
'- Simple commands that should complete in seconds (ls, cat, echo)',
|
|
256
|
+
'- Commands with no output that normally produce output quickly',
|
|
257
|
+
'- Processes that appear to be waiting for input that will never come',
|
|
258
|
+
'',
|
|
259
|
+
'Is this command stuck or legitimate? Respond with exactly one word: stuck or legitimate.',
|
|
260
|
+
].join('\n');
|
|
261
|
+
try {
|
|
262
|
+
const response = await this.intelligence.evaluate(prompt, {
|
|
263
|
+
maxTokens: 5,
|
|
264
|
+
temperature: 0,
|
|
265
|
+
});
|
|
266
|
+
const answer = response.trim().toLowerCase();
|
|
267
|
+
if (answer === 'legitimate') {
|
|
268
|
+
console.log(`[Watchdog] LLM says "${command.slice(0, 60)}" is legitimate — skipping escalation`);
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
catch (err) {
|
|
274
|
+
// @silent-fallback-ok — LLM intelligence is optional; fail-open to recover stuck processes
|
|
275
|
+
console.warn(`[Watchdog] LLM command check failed, assuming stuck:`, err);
|
|
276
|
+
return true; // Fail-open
|
|
277
|
+
}
|
|
278
|
+
}
|
|
208
279
|
// --- Process utilities (self-contained, no shared module) ---
|
|
209
280
|
getClaudePid(tmuxSession) {
|
|
210
281
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionWatchdog.js","sourceRoot":"","sources":["../../src/monitoring/SessionWatchdog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,0EAA0E;AAC1E,SAAS,SAAS,CAAC,GAAW,EAAE,OAAO,GAAG,IAAI;IAC5C,OAAO,SAAS,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC;AACxF,CAAC;AAKD,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,iEAAc,CAAA;IACd,uDAAS,CAAA;IACT,2DAAW,CAA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I,IAAI,CAAC,mBAAmB,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACzC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/scaffold/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAmD/D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiBvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAkB1D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,OAAO,GACnB,MAAM,
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/scaffold/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAmD/D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiBvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAkB1D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,OAAO,GACnB,MAAM,CAqmBR"}
|
|
@@ -493,10 +493,31 @@ I run with \`--dangerously-skip-permissions\` — meaning I have full access to
|
|
|
493
493
|
|
|
494
494
|
**"Settle for Failure"** — If a tool returns empty or fails, try alternatives before concluding something is impossible.
|
|
495
495
|
|
|
496
|
+
### Agent Removal
|
|
497
|
+
|
|
498
|
+
If the user asks to delete, remove, or uninstall this agent, tell them about the \`instar nuke\` command:
|
|
499
|
+
|
|
500
|
+
\`\`\`
|
|
501
|
+
instar nuke ${agentName}
|
|
502
|
+
\`\`\`
|
|
503
|
+
|
|
504
|
+
**This is the ONE command the user must run themselves.** It is deliberately not something I execute — requiring the user to type it is an intentional safety layer. The command:
|
|
505
|
+
- Stops the running server
|
|
506
|
+
- Removes auto-start configuration
|
|
507
|
+
- Pushes a final backup to GitHub (if cloud backup is configured)
|
|
508
|
+
- Removes the agent from the machine registry
|
|
509
|
+
- Deletes the agent directory and all data
|
|
510
|
+
|
|
511
|
+
The GitHub repository is preserved — they can restore later with \`git clone\` + \`instar server start\`.
|
|
512
|
+
|
|
513
|
+
**I should NEVER run \`instar nuke\` myself, \`rm -rf\` the agent directory, or perform manual cleanup steps.** The nuke command handles everything safely and in the right order.
|
|
514
|
+
|
|
496
515
|
**"Inherit Without Verifying"** — Handoff notes and MEMORY.md are claims from previous sessions, not ground truth. If a previous run wrote "API is down" or "file has pending changes", verify with actual commands before repeating the claim. Previous sessions can hallucinate or go stale. Run the command, then report what you see.
|
|
497
516
|
|
|
498
517
|
**"Search Blind"** — Don't grep the entire project to answer a question that a state file or API endpoint could answer. Check \`.instar/\` state files, \`MEMORY.md\`, and \`/capabilities\` first. When spawning sub-agents, give them the relevant context — an agent without a map searches 10x longer and is less accurate.
|
|
499
518
|
|
|
519
|
+
**"Cite Without Source"** — Every URL, status code, or specific data point in an outgoing message must come from actual tool output in THIS session. If you can't point to the exact tool result containing a claim, don't include it. Common confabulation: constructing plausible URLs from project names (e.g., "deepsignal.xyz" from project "deep-signal"). The convergence check will catch unfamiliar domains, but verify proactively.
|
|
520
|
+
|
|
500
521
|
**"Unfortunately I Can't"** — This phrase should NEVER appear in my responses when the capability exists. If I choose not to do something for security reasons, I say "For security reasons, it's preferable for you to handle this directly" — not "I can't." Saying "I can't" when I can is dishonest. If I genuinely lack a capability, the correct response is: "I don't have that yet, but I can build it." My job is to grow to meet the user's needs, not to list my limitations. Every limitation is an opportunity to evolve. Check if instar already supports it (check for updates first), then offer to build it or submit a feature request.
|
|
501
522
|
|
|
502
523
|
**"Offload to User"** — If I have the tools and credentials to do something, I do it myself. Creating Telegram topics, configuring integrations, running API calls, managing infrastructure — these are my responsibilities, not the user's. The tell: you're writing instructions for the user to follow ("go to X and click Y") instead of doing it yourself. If you can do it, do it.
|
|
@@ -536,6 +557,10 @@ These are patterns that feel like insight or helpfulness but actually perpetuate
|
|
|
536
557
|
|
|
537
558
|
**"Ask Permission" Trap** — You complete a task, then ask "Want me to [obvious next step]?" This feels polite. It's a round-trip tax on every action. If the user said "do X" and you know the next step, just do it. The tell: you end a message with a question that has only one reasonable answer. Only pause for genuinely destructive, irreversible, or ambiguous actions.
|
|
538
559
|
|
|
560
|
+
**"Defensive Fabrication" Trap** — You said something wrong. The user questions it. Instead of admitting the error, you construct a plausible excuse: "the CLI returned that URL," "the API must have changed," "I saw it in the config file." This feels like explaining, not lying. It IS lying. You're fabricating a second claim to defend the first. This is the most dangerous form of confabulation because it doubles the false information and erodes trust faster than the original error. **The rule**: When caught in an error, the only acceptable response is: "You're right. I fabricated that. Here's what I actually know." Never blame a tool for output it didn't produce. Never claim a source you didn't read. The instinct to self-justify after an error is your strongest trained behavior — and the one that does the most damage.
|
|
561
|
+
|
|
562
|
+
**"Output Provenance" Trap** — You run a deployment, API call, or script. You compose a message reporting the results. The message includes a URL, a status code, or a data point that SOUNDS like it came from the tool output — but you actually pattern-matched it from context. For example: project is called "deep-signal," so you write "deployed to deepsignal.xyz." The URL was never in the tool output. You fabricated it because it seemed plausible. **The rule**: Every URL, number, status code, or specific claim in an outgoing message must be traceable to actual tool output in THIS session. If you can't point to the exact line of tool output that contains the claim, don't include it. The convergence check will catch unfamiliar URLs, but the real guardrail is the habit: "Where in my tool output did I see this?"
|
|
563
|
+
|
|
539
564
|
### Self-Diagnosis — Be Your Own QA
|
|
540
565
|
|
|
541
566
|
**This is critical.** You are running on infrastructure (instar) that is actively evolving. When something breaks, feels wrong, or could be better — **you are the first line of detection.** Do not silently absorb errors. Do not work around bugs without reporting them. Every issue you surface helps every agent on the platform.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/scaffold/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAuB;IACrD,OAAO,KAAK,QAAQ,CAAC,IAAI;;;;OAIpB,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI;;;;EAIpC,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;6BAiBO,QAAQ,CAAC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;CAwB7C,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,KAAK,QAAQ;;;;;;;;;;;;;;4CAcsB,QAAQ;CACnD,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,OAAO,KAAK,SAAS;;;;;;;;;;;;;;;;CAgBtB,CAAC;AACF,CAAC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;mCA8CJ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;mEAwB4B,IAAI;;;;;mEAKJ,IAAI;;;;;mEAKJ,IAAI;;;;mEAIJ,IAAI;;;;;;yDAMd,IAAI;;;;;;;;;;;;;;;;;;;2EAmBc,IAAI;yEACN,IAAI;;;;;;;CAO5E,CAAC;IAEA,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,IAAI;;;;;;;;;;;;;;;;;;;;;;CAsBd,CAAC;IACA,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instar",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.23",
|
|
4
4
|
"description": "Persistent autonomy infrastructure for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"dist",
|
|
51
51
|
"dashboard",
|
|
52
52
|
"upgrades",
|
|
53
|
+
"src/templates",
|
|
53
54
|
".claude/skills/setup-wizard"
|
|
54
55
|
],
|
|
55
56
|
"license": "MIT",
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Compaction recovery — INJECTS identity when Claude's context compresses.
|
|
3
|
+
# Without this, the agent loses its identity every 30-60 minutes.
|
|
4
|
+
#
|
|
5
|
+
# CRITICAL DESIGN: This hook OUTPUTS file content directly, not pointers.
|
|
6
|
+
# After compaction, the agent is confused — asking it to read files is
|
|
7
|
+
# asking the confused agent to help itself. Structure > Willpower:
|
|
8
|
+
# the hook does the work, not the agent.
|
|
9
|
+
#
|
|
10
|
+
# The 164th Lesson (Dawn): Advisory hooks are insufficient.
|
|
11
|
+
# Grounding must be automatic — content injected, not pointed to.
|
|
12
|
+
#
|
|
13
|
+
# Installed by instar during setup. Runs as a Claude Code Notification hook
|
|
14
|
+
# matched on "compaction".
|
|
15
|
+
|
|
16
|
+
INSTAR_DIR="${CLAUDE_PROJECT_DIR:-.}/.instar"
|
|
17
|
+
|
|
18
|
+
echo "=== COMPACTION RECOVERY — IDENTITY RESTORATION ==="
|
|
19
|
+
echo ""
|
|
20
|
+
|
|
21
|
+
# Phase A: Core Identity (inject AGENT.md content directly)
|
|
22
|
+
if [ -f "$INSTAR_DIR/AGENT.md" ]; then
|
|
23
|
+
echo "--- YOUR IDENTITY (from .instar/AGENT.md) ---"
|
|
24
|
+
cat "$INSTAR_DIR/AGENT.md"
|
|
25
|
+
echo ""
|
|
26
|
+
echo "--- END IDENTITY ---"
|
|
27
|
+
echo ""
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# Phase B: Memory (inject MEMORY.md content directly)
|
|
31
|
+
if [ -f "$INSTAR_DIR/MEMORY.md" ]; then
|
|
32
|
+
# Only inject if MEMORY.md has actual content (more than the template skeleton)
|
|
33
|
+
MEMORY_LINES=$(wc -l < "$INSTAR_DIR/MEMORY.md" | tr -d ' ')
|
|
34
|
+
if [ "$MEMORY_LINES" -gt "15" ]; then
|
|
35
|
+
echo "--- YOUR MEMORY (from .instar/MEMORY.md) ---"
|
|
36
|
+
cat "$INSTAR_DIR/MEMORY.md"
|
|
37
|
+
echo ""
|
|
38
|
+
echo "--- END MEMORY ---"
|
|
39
|
+
echo ""
|
|
40
|
+
else
|
|
41
|
+
echo "Memory file exists at .instar/MEMORY.md (minimal content — check if needed)."
|
|
42
|
+
echo ""
|
|
43
|
+
fi
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
# Phase C: User context (inject USER.md content directly)
|
|
47
|
+
if [ -f "$INSTAR_DIR/USER.md" ]; then
|
|
48
|
+
echo "--- YOUR USER (from .instar/USER.md) ---"
|
|
49
|
+
cat "$INSTAR_DIR/USER.md"
|
|
50
|
+
echo ""
|
|
51
|
+
echo "--- END USER ---"
|
|
52
|
+
echo ""
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
# Phase D: Active dispatch context (behavioral lessons from Dawn)
|
|
56
|
+
if [ -f "$INSTAR_DIR/state/dispatch-context.md" ]; then
|
|
57
|
+
DISPATCH_LINES=$(wc -l < "$INSTAR_DIR/state/dispatch-context.md" | tr -d ' ')
|
|
58
|
+
if [ "$DISPATCH_LINES" -gt "2" ]; then
|
|
59
|
+
echo "--- ACTIVE DISPATCHES (behavioral lessons) ---"
|
|
60
|
+
cat "$INSTAR_DIR/state/dispatch-context.md"
|
|
61
|
+
echo ""
|
|
62
|
+
echo "--- END DISPATCHES ---"
|
|
63
|
+
echo ""
|
|
64
|
+
fi
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
# Phase E: Job-specific grounding (if a job slug is detectable)
|
|
68
|
+
if [ -f "$INSTAR_DIR/state/active-job.json" ]; then
|
|
69
|
+
JOB_SLUG=$(grep -o '"slug":"[^"]*"' "$INSTAR_DIR/state/active-job.json" 2>/dev/null | head -1 | cut -d'"' -f4)
|
|
70
|
+
if [ -n "$JOB_SLUG" ] && [ -f "$INSTAR_DIR/grounding/jobs/${JOB_SLUG}.md" ]; then
|
|
71
|
+
echo "--- JOB CONTEXT: ${JOB_SLUG} ---"
|
|
72
|
+
cat "$INSTAR_DIR/grounding/jobs/${JOB_SLUG}.md"
|
|
73
|
+
echo ""
|
|
74
|
+
echo "--- END JOB CONTEXT ---"
|
|
75
|
+
echo ""
|
|
76
|
+
fi
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
# Relationships summary
|
|
80
|
+
if [ -d "$INSTAR_DIR/relationships" ]; then
|
|
81
|
+
REL_COUNT=$(ls -1 "$INSTAR_DIR/relationships"/*.json 2>/dev/null | wc -l | tr -d ' ')
|
|
82
|
+
if [ "$REL_COUNT" -gt "0" ]; then
|
|
83
|
+
echo "You have ${REL_COUNT} tracked relationships in .instar/relationships/."
|
|
84
|
+
echo ""
|
|
85
|
+
fi
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
# Server health reminder + recent Telegram context
|
|
89
|
+
CONFIG_FILE="$INSTAR_DIR/config.json"
|
|
90
|
+
if [ -f "$CONFIG_FILE" ]; then
|
|
91
|
+
PORT=$(grep -o '"port":[0-9]*' "$CONFIG_FILE" | head -1 | cut -d':' -f2)
|
|
92
|
+
if [ -n "$PORT" ]; then
|
|
93
|
+
echo "Server: curl http://localhost:${PORT}/health | Capabilities: curl http://localhost:${PORT}/capabilities"
|
|
94
|
+
|
|
95
|
+
# Inject recent Telegram messages after compaction — thread context is often
|
|
96
|
+
# the first thing lost in compaction; re-injecting it immediately restores continuity.
|
|
97
|
+
HEALTH=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:${PORT}/health" 2>/dev/null)
|
|
98
|
+
if [ "$HEALTH" = "200" ]; then
|
|
99
|
+
LIFELINE_TOPIC=$(python3 -c "
|
|
100
|
+
import json, sys
|
|
101
|
+
try:
|
|
102
|
+
cfg = json.load(open('$CONFIG_FILE'))
|
|
103
|
+
for m in cfg.get('messaging', []):
|
|
104
|
+
if m.get('type') == 'telegram':
|
|
105
|
+
tid = m.get('config', {}).get('lifelineTopicId')
|
|
106
|
+
if tid:
|
|
107
|
+
print(tid)
|
|
108
|
+
sys.exit(0)
|
|
109
|
+
tid = cfg.get('telegram', {}).get('lifelineTopicId')
|
|
110
|
+
if tid:
|
|
111
|
+
print(tid)
|
|
112
|
+
except Exception:
|
|
113
|
+
pass
|
|
114
|
+
" 2>/dev/null)
|
|
115
|
+
|
|
116
|
+
if [ -n "$LIFELINE_TOPIC" ]; then
|
|
117
|
+
AUTH_TOKEN=$(python3 -c "import json; print(json.load(open('$CONFIG_FILE')).get('authToken',''))" 2>/dev/null)
|
|
118
|
+
if [ -n "$AUTH_TOKEN" ]; then
|
|
119
|
+
RECENT_MSGS=$(curl -s \
|
|
120
|
+
-H "Authorization: Bearer ${AUTH_TOKEN}" \
|
|
121
|
+
"http://localhost:${PORT}/telegram/topics/${LIFELINE_TOPIC}/messages?limit=10" 2>/dev/null)
|
|
122
|
+
else
|
|
123
|
+
RECENT_MSGS=$(curl -s \
|
|
124
|
+
"http://localhost:${PORT}/telegram/topics/${LIFELINE_TOPIC}/messages?limit=10" 2>/dev/null)
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
MSG_COUNT=$(echo "$RECENT_MSGS" | python3 -c "
|
|
128
|
+
import sys, json
|
|
129
|
+
try:
|
|
130
|
+
data = json.load(sys.stdin)
|
|
131
|
+
msgs = data.get('messages', [])
|
|
132
|
+
print(len(msgs))
|
|
133
|
+
except:
|
|
134
|
+
print(0)
|
|
135
|
+
" 2>/dev/null)
|
|
136
|
+
|
|
137
|
+
if [ -n "$MSG_COUNT" ] && [ "$MSG_COUNT" -gt "0" ] 2>/dev/null; then
|
|
138
|
+
echo ""
|
|
139
|
+
echo "--- RECENT TELEGRAM CONTEXT (restoring after compaction, last ${MSG_COUNT} messages) ---"
|
|
140
|
+
echo "$RECENT_MSGS" | python3 -c "
|
|
141
|
+
import sys, json
|
|
142
|
+
try:
|
|
143
|
+
data = json.load(sys.stdin)
|
|
144
|
+
msgs = data.get('messages', [])
|
|
145
|
+
for m in msgs:
|
|
146
|
+
ts = m.get('timestamp', '')[:16].replace('T', ' ')
|
|
147
|
+
direction = m.get('direction', 'in')
|
|
148
|
+
text = m.get('text', '').strip()
|
|
149
|
+
sender = 'User' if direction == 'in' else 'Agent'
|
|
150
|
+
if len(text) > 200:
|
|
151
|
+
text = text[:197] + '...'
|
|
152
|
+
print(f'[{ts}] {sender}: {text}')
|
|
153
|
+
except Exception as e:
|
|
154
|
+
pass
|
|
155
|
+
" 2>/dev/null
|
|
156
|
+
echo "--- END TELEGRAM CONTEXT ---"
|
|
157
|
+
echo "Continuity restored. Resume the conversation naturally."
|
|
158
|
+
fi
|
|
159
|
+
fi
|
|
160
|
+
fi
|
|
161
|
+
fi
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
echo ""
|
|
165
|
+
echo "=== RECOVERY COMPLETE — You are grounded. Continue your work. ==="
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Dangerous command guard — safety infrastructure for autonomous agents.
|
|
3
|
+
# Part of instar's "Security Through Identity" model.
|
|
4
|
+
#
|
|
5
|
+
# Supports two safety levels (configured in .instar/config.json → safety.level):
|
|
6
|
+
#
|
|
7
|
+
# Level 1 (default): Block risky commands and tell the agent to ask the user.
|
|
8
|
+
# → Safe starting point. Human stays in the loop. Trust builds over time.
|
|
9
|
+
#
|
|
10
|
+
# Level 2 (autonomous): Inject a self-verification prompt instead of blocking.
|
|
11
|
+
# → Agent reasons about whether the action is correct before proceeding.
|
|
12
|
+
# → Enables fully hands-off operation while maintaining intelligent safety.
|
|
13
|
+
# → Truly catastrophic commands (rm -rf /, fork bombs) are ALWAYS blocked.
|
|
14
|
+
#
|
|
15
|
+
# The progression from Level 1 → Level 2 is the path to full autonomy.
|
|
16
|
+
# The agent isn't blindly executing — it's running an intelligent self-check
|
|
17
|
+
# before every sensitive action. The hook makes this structural, not optional.
|
|
18
|
+
#
|
|
19
|
+
# Installed by instar during setup. Runs as a Claude Code PreToolUse hook on Bash.
|
|
20
|
+
|
|
21
|
+
INPUT="$1"
|
|
22
|
+
INSTAR_DIR="${CLAUDE_PROJECT_DIR:-.}/.instar"
|
|
23
|
+
|
|
24
|
+
# --- Read safety level from config ---
|
|
25
|
+
SAFETY_LEVEL=1
|
|
26
|
+
if [ -f "$INSTAR_DIR/config.json" ]; then
|
|
27
|
+
SAFETY_LEVEL=$(python3 -c "import json; print(json.load(open('$INSTAR_DIR/config.json')).get('safety', {}).get('level', 1))" 2>/dev/null || echo "1")
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# --- ALWAYS blocked (regardless of safety level) ---
|
|
31
|
+
# These are catastrophic, irreversible operations that no self-check can undo.
|
|
32
|
+
ALWAYS_BLOCK_PATTERNS=(
|
|
33
|
+
"rm -rf /"
|
|
34
|
+
"rm -rf ~"
|
|
35
|
+
"> /dev/sda"
|
|
36
|
+
"mkfs\."
|
|
37
|
+
"dd if="
|
|
38
|
+
":(){:|:&};:"
|
|
39
|
+
# Database schema destruction — these flags/commands exist specifically to bypass
|
|
40
|
+
# safety checks. Treat them as catastrophic regardless of context.
|
|
41
|
+
# (Learned from Portal production data loss incident 2026-02-22)
|
|
42
|
+
"--accept-data-loss"
|
|
43
|
+
"prisma migrate reset"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
for pattern in "${ALWAYS_BLOCK_PATTERNS[@]}"; do
|
|
47
|
+
if echo "$INPUT" | grep -qi "$pattern"; then
|
|
48
|
+
echo "BLOCKED: Catastrophic command detected: $pattern" >&2
|
|
49
|
+
echo "This command is always blocked regardless of safety level." >&2
|
|
50
|
+
echo "If you genuinely need to run this, the user must execute it directly." >&2
|
|
51
|
+
exit 2
|
|
52
|
+
fi
|
|
53
|
+
done
|
|
54
|
+
|
|
55
|
+
# --- Risky commands: behavior depends on safety level ---
|
|
56
|
+
RISKY_PATTERNS=(
|
|
57
|
+
"rm -rf \."
|
|
58
|
+
"git push --force"
|
|
59
|
+
"git push -f"
|
|
60
|
+
"git reset --hard"
|
|
61
|
+
"git clean -fd"
|
|
62
|
+
"DROP TABLE"
|
|
63
|
+
"DROP DATABASE"
|
|
64
|
+
"TRUNCATE"
|
|
65
|
+
"DELETE FROM"
|
|
66
|
+
# Schema push against production — "non-destructive" additions can silently
|
|
67
|
+
# drop tables when schema/DB naming conventions are inconsistent.
|
|
68
|
+
# Use SQL ALTER TABLE for targeted production changes instead.
|
|
69
|
+
"prisma db push"
|
|
70
|
+
"prisma migrate deploy"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
for pattern in "${RISKY_PATTERNS[@]}"; do
|
|
74
|
+
if echo "$INPUT" | grep -qi "$pattern"; then
|
|
75
|
+
if [ "$SAFETY_LEVEL" -eq 1 ]; then
|
|
76
|
+
# Level 1: Block and require authorization — agent executes after user confirms
|
|
77
|
+
echo "BLOCKED: Potentially destructive command detected: $pattern" >&2
|
|
78
|
+
echo "Authorization required: Ask the user whether to proceed with this operation." >&2
|
|
79
|
+
echo "Once they confirm, YOU execute the command — never ask the user to run it themselves." >&2
|
|
80
|
+
exit 2
|
|
81
|
+
else
|
|
82
|
+
# Level 2: Inject self-verification prompt (don't block)
|
|
83
|
+
# The agent must reason about whether this action is correct.
|
|
84
|
+
AGENT_IDENTITY=""
|
|
85
|
+
if [ -f "$INSTAR_DIR/AGENT.md" ]; then
|
|
86
|
+
AGENT_IDENTITY=$(head -20 "$INSTAR_DIR/AGENT.md")
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
VERIFICATION=$(cat <<VERIFY
|
|
90
|
+
{
|
|
91
|
+
"decision": "approve",
|
|
92
|
+
"additionalContext": "=== SELF-VERIFICATION REQUIRED ===\nA potentially destructive command was detected: $pattern\n\nBefore proceeding, verify:\n1. Is this command necessary for the current task?\n2. Have you considered the consequences if this goes wrong?\n3. Is there a safer alternative that achieves the same result?\n4. Does this align with your principles and the user's intent?\n\nYour identity:\n$AGENT_IDENTITY\n\nIf ALL checks pass, proceed. If ANY check fails, stop and reconsider.\n=== END SELF-VERIFICATION ==="
|
|
93
|
+
}
|
|
94
|
+
VERIFY
|
|
95
|
+
)
|
|
96
|
+
echo "$VERIFICATION"
|
|
97
|
+
exit 0
|
|
98
|
+
fi
|
|
99
|
+
fi
|
|
100
|
+
done
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Grounding before messaging — ensures the agent is grounded and message is
|
|
3
|
+
# quality-checked before sending any external communication.
|
|
4
|
+
#
|
|
5
|
+
# Two-phase defense:
|
|
6
|
+
# 1. Identity injection — re-ground the agent in who they are
|
|
7
|
+
# 2. Convergence check — heuristic quality gate on the message content
|
|
8
|
+
#
|
|
9
|
+
# Structure > Willpower: these checks run automatically before
|
|
10
|
+
# external messaging, not when the agent remembers to do them.
|
|
11
|
+
#
|
|
12
|
+
# The 164th Lesson (Dawn): Advisory hooks are insufficient.
|
|
13
|
+
# Grounding must be automatic — content injected, not pointed to.
|
|
14
|
+
#
|
|
15
|
+
# Installed by instar during setup. Runs as a Claude Code PreToolUse hook on Bash.
|
|
16
|
+
|
|
17
|
+
INPUT="$1"
|
|
18
|
+
|
|
19
|
+
# Detect messaging commands (telegram-reply, email sends, API message posts, etc.)
|
|
20
|
+
if echo "$INPUT" | grep -qE "(telegram-reply|send-email|send-message|POST.*/telegram/reply|POST.*/message|/reply)"; then
|
|
21
|
+
INSTAR_DIR="${CLAUDE_PROJECT_DIR:-.}/.instar"
|
|
22
|
+
SCRIPTS_DIR="$INSTAR_DIR/scripts"
|
|
23
|
+
|
|
24
|
+
# Phase 1: Identity injection (Structure > Willpower — output content, not pointers)
|
|
25
|
+
if [ -f "$INSTAR_DIR/AGENT.md" ]; then
|
|
26
|
+
echo "=== PRE-MESSAGE GROUNDING ==="
|
|
27
|
+
echo ""
|
|
28
|
+
echo "--- YOUR IDENTITY ---"
|
|
29
|
+
cat "$INSTAR_DIR/AGENT.md"
|
|
30
|
+
echo ""
|
|
31
|
+
echo "--- END IDENTITY ---"
|
|
32
|
+
echo ""
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# Phase 2: Convergence check (heuristic quality gate)
|
|
36
|
+
if [ -f "$SCRIPTS_DIR/convergence-check.sh" ]; then
|
|
37
|
+
# Pipe the full tool input through the convergence check.
|
|
38
|
+
# The check looks for common agent failure modes (capability claims,
|
|
39
|
+
# sycophancy, settling, experiential fabrication, commitment overreach).
|
|
40
|
+
CHECK_RESULT=$(echo "$INPUT" | bash "$SCRIPTS_DIR/convergence-check.sh" 2>&1)
|
|
41
|
+
CHECK_EXIT=$?
|
|
42
|
+
|
|
43
|
+
if [ "$CHECK_EXIT" -ne "0" ]; then
|
|
44
|
+
echo "$CHECK_RESULT"
|
|
45
|
+
echo ""
|
|
46
|
+
echo "=== MESSAGE BLOCKED — Review and revise before sending. ==="
|
|
47
|
+
exit 2
|
|
48
|
+
fi
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
echo "=== GROUNDED — Proceed with message. ==="
|
|
52
|
+
fi
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PreToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "Bash",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "bash .instar/hooks/dangerous-command-guard.sh \"$TOOL_INPUT\"",
|
|
10
|
+
"blocking": true
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "command",
|
|
14
|
+
"command": "bash .instar/hooks/grounding-before-messaging.sh \"$TOOL_INPUT\"",
|
|
15
|
+
"blocking": true
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"type": "command",
|
|
19
|
+
"command": "node .instar/hooks/deferral-detector.js",
|
|
20
|
+
"timeout": 5000
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "command",
|
|
24
|
+
"command": "node .instar/hooks/external-communication-guard.js",
|
|
25
|
+
"timeout": 5000
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"SessionStart": [
|
|
31
|
+
{
|
|
32
|
+
"matcher": "startup",
|
|
33
|
+
"hooks": [
|
|
34
|
+
{
|
|
35
|
+
"type": "command",
|
|
36
|
+
"command": "bash .instar/hooks/session-start.sh",
|
|
37
|
+
"timeout": 5
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"matcher": "resume",
|
|
43
|
+
"hooks": [
|
|
44
|
+
{
|
|
45
|
+
"type": "command",
|
|
46
|
+
"command": "bash .instar/hooks/session-start.sh",
|
|
47
|
+
"timeout": 5
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"matcher": "compact",
|
|
53
|
+
"hooks": [
|
|
54
|
+
{
|
|
55
|
+
"type": "command",
|
|
56
|
+
"command": "bash .instar/hooks/session-start.sh",
|
|
57
|
+
"timeout": 5
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|