notsleep 1.0.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 +117 -0
- package/LICENSE +21 -0
- package/README.md +341 -0
- package/dashboard/index.html +893 -0
- package/dist/agent.d.ts +162 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +1064 -0
- package/dist/agent.js.map +1 -0
- package/dist/api.d.ts +10 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +39 -0
- package/dist/api.js.map +1 -0
- package/dist/checkpoint.d.ts +52 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +234 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +265 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +15 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +237 -0
- package/dist/context.js.map +1 -0
- package/dist/cost.d.ts +26 -0
- package/dist/cost.d.ts.map +1 -0
- package/dist/cost.js +161 -0
- package/dist/cost.js.map +1 -0
- package/dist/dashboard.d.ts +96 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +292 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/fileconfig.d.ts +129 -0
- package/dist/fileconfig.d.ts.map +1 -0
- package/dist/fileconfig.js +391 -0
- package/dist/fileconfig.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +882 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +9 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +221 -0
- package/dist/init.js.map +1 -0
- package/dist/logger.d.ts +33 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +150 -0
- package/dist/logger.js.map +1 -0
- package/dist/modelsdev.d.ts +63 -0
- package/dist/modelsdev.d.ts.map +1 -0
- package/dist/modelsdev.js +265 -0
- package/dist/modelsdev.js.map +1 -0
- package/dist/parallel.d.ts +54 -0
- package/dist/parallel.d.ts.map +1 -0
- package/dist/parallel.js +139 -0
- package/dist/parallel.js.map +1 -0
- package/dist/pool.d.ts +17 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +53 -0
- package/dist/pool.js.map +1 -0
- package/dist/provider.d.ts +60 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +396 -0
- package/dist/provider.js.map +1 -0
- package/dist/registry.d.ts +60 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +153 -0
- package/dist/registry.js.map +1 -0
- package/dist/safety.d.ts +21 -0
- package/dist/safety.d.ts.map +1 -0
- package/dist/safety.js +118 -0
- package/dist/safety.js.map +1 -0
- package/dist/schema.d.ts +9 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +166 -0
- package/dist/schema.js.map +1 -0
- package/dist/test-dashboard.d.ts +5 -0
- package/dist/test-dashboard.d.ts.map +1 -0
- package/dist/test-dashboard.js +202 -0
- package/dist/test-dashboard.js.map +1 -0
- package/dist/tools.d.ts +27 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +1212 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +180 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/dist/worktree.d.ts +50 -0
- package/dist/worktree.d.ts.map +1 -0
- package/dist/worktree.js +186 -0
- package/dist/worktree.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safety.d.ts","sourceRoot":"","sources":["../src/safety.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAOnE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACpB;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAezD;AA2BD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWhE"}
|
package/dist/safety.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// NotSleep - Safety guards
|
|
4
|
+
// ============================================================
|
|
5
|
+
// These guards exist to protect the user's machine from an autonomous
|
|
6
|
+
// agent accidentally deleting or overwriting data outside its workspace.
|
|
7
|
+
// They are enforced in CODE (not just the prompt) so they cannot be
|
|
8
|
+
// "forgotten" or talked around by the model.
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.isPathWithin = isPathWithin;
|
|
44
|
+
exports.assertWritablePath = assertWritablePath;
|
|
45
|
+
exports.checkShellCommand = checkShellCommand;
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const os = __importStar(require("os"));
|
|
48
|
+
/**
|
|
49
|
+
* True if `child` is the same as, or nested inside, `parent`.
|
|
50
|
+
* Comparison is case-insensitive on Windows (path.relative handles this).
|
|
51
|
+
*/
|
|
52
|
+
function isPathWithin(child, parent) {
|
|
53
|
+
const resolvedChild = path.resolve(child);
|
|
54
|
+
const resolvedParent = path.resolve(parent);
|
|
55
|
+
const rel = path.relative(resolvedParent, resolvedChild);
|
|
56
|
+
// Same dir => '' ; nested => no leading '..' and not an absolute path
|
|
57
|
+
// (an absolute rel happens when they're on different Windows drives).
|
|
58
|
+
return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Decide whether a file-writing/deleting operation is allowed to touch
|
|
62
|
+
* `target`. Writes are confined to the workspace root or the OS temp dir.
|
|
63
|
+
* Returns the resolved absolute path when allowed, or a reason when not.
|
|
64
|
+
*/
|
|
65
|
+
function assertWritablePath(target, workspaceRoot) {
|
|
66
|
+
const resolved = path.resolve(target);
|
|
67
|
+
if (isPathWithin(resolved, workspaceRoot)) {
|
|
68
|
+
return { allowed: true, resolved };
|
|
69
|
+
}
|
|
70
|
+
if (isPathWithin(resolved, os.tmpdir())) {
|
|
71
|
+
return { allowed: true, resolved };
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
allowed: false,
|
|
75
|
+
resolved,
|
|
76
|
+
reason: `Refused: "${resolved}" is outside the workspace (${path.resolve(workspaceRoot)}). ` +
|
|
77
|
+
`For your safety, writing/modifying files outside the workspace is not allowed.`,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Patterns for shell commands that can destroy data. Covers Windows
|
|
82
|
+
* PowerShell/cmd and POSIX. PowerShell aliases (rm, del, rmdir, rd, ri,
|
|
83
|
+
* erase) all map to Remove-Item, so blocking those names covers them.
|
|
84
|
+
*/
|
|
85
|
+
const DANGEROUS_PATTERNS = [
|
|
86
|
+
{ re: /\bRemove-Item\b/i, label: 'Remove-Item' },
|
|
87
|
+
{ re: /\bRemove-ItemProperty\b/i, label: 'Remove-ItemProperty' },
|
|
88
|
+
{ re: /\bClear-Content\b/i, label: 'Clear-Content' },
|
|
89
|
+
{ re: /\bClear-Item\b/i, label: 'Clear-Item' },
|
|
90
|
+
{ re: /\bFormat-Volume\b/i, label: 'Format-Volume' },
|
|
91
|
+
{ re: /\brm\b/i, label: 'rm' },
|
|
92
|
+
{ re: /\brmdir\b/i, label: 'rmdir' },
|
|
93
|
+
{ re: /\brd\s+\/s/i, label: 'rd /s' },
|
|
94
|
+
{ re: /\bdel\b/i, label: 'del' },
|
|
95
|
+
{ re: /\berase\b/i, label: 'erase' },
|
|
96
|
+
{ re: /\bri\s/i, label: 'ri (Remove-Item alias)' },
|
|
97
|
+
{ re: /(?:^|[;&|]\s*)format\b/i, label: 'format (disk)' },
|
|
98
|
+
{ re: /\bmkfs\b/i, label: 'mkfs' },
|
|
99
|
+
{ re: /\bdd\s+if=/i, label: 'dd' },
|
|
100
|
+
{ re: /\bgit\s+clean\b/i, label: 'git clean' },
|
|
101
|
+
{ re: /\bshutdown\b/i, label: 'shutdown' },
|
|
102
|
+
{ re: /\bReset-Computer\b/i, label: 'Reset-Computer' },
|
|
103
|
+
];
|
|
104
|
+
/**
|
|
105
|
+
* Inspect a shell command for destructive operations. Returns a human
|
|
106
|
+
* reason string if the command should be refused, or null if it is allowed.
|
|
107
|
+
*/
|
|
108
|
+
function checkShellCommand(command) {
|
|
109
|
+
for (const { re, label } of DANGEROUS_PATTERNS) {
|
|
110
|
+
if (re.test(command)) {
|
|
111
|
+
return (`Refused: shell command appears to contain a destructive operation ("${label}"). ` +
|
|
112
|
+
`For your safety, file deletion / disk / power commands are blocked. ` +
|
|
113
|
+
`If you need to remove a file you created, overwrite it with write_file instead.`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=safety.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safety.js","sourceRoot":"","sources":["../src/safety.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,2BAA2B;AAC3B,+DAA+D;AAC/D,sEAAsE;AACtE,yEAAyE;AACzE,oEAAoE;AACpE,6CAA6C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAS7C,oCAOC;AAOD,gDAkBC;AA+BD,8CAWC;AAjFD,2CAA6B;AAC7B,uCAAyB;AAEzB;;;GAGG;AACH,SAAgB,YAAY,CAAC,KAAa,EAAE,MAAc;IACxD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;IACzD,sEAAsE;IACtE,sEAAsE;IACtE,OAAO,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAA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AK,EAAE;IAChC,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE;IACpC,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,wBAAwB,EAAE;IAClD,EAAE,EAAE,EAAE,yBAAyB,EAAE,KAAK,EAAE,eAAe,EAAE;IACzD,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE;IAClC,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE;IAClC,EAAE,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,WAAW,EAAE;IAC9C,EAAE,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,EAAE;IAC1C,EAAE,EAAE,EAAE,qBAAqB,EAAE,KAAK,EAAE,gBAAgB,EAAE;CACvD,CAAC;AAEF;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,KAAK,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,kBAAkB,EAAE,CAAC;QAC/C,IAAI,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACrB,OAAO,CACL,uEAAuE,KAAK,MAAM;gBAClF,sEAAsE;gBACtE,iFAAiF,CAClF,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The JSON Schema object describing a notsleep.json file. */
|
|
2
|
+
export declare const NOTSLEEP_JSON_SCHEMA: Record<string, unknown>;
|
|
3
|
+
/** Serialize the schema to pretty JSON. */
|
|
4
|
+
export declare function schemaJson(): string;
|
|
5
|
+
/** Write the schema file, creating parent directories as needed. Returns the path. */
|
|
6
|
+
export declare function writeSchemaFile(filePath: string): string;
|
|
7
|
+
/** Default filename for the generated schema, written beside the config file. */
|
|
8
|
+
export declare const DEFAULT_SCHEMA_FILENAME = "notsleep.schema.json";
|
|
9
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAwBA,8DAA8D;AAC9D,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAkGxD,CAAC;AAEF,2CAA2C;AAC3C,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED,iFAAiF;AACjF,eAAO,MAAM,uBAAuB,yBAAyB,CAAC"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// NotSleep - JSON Schema for notsleep.json
|
|
4
|
+
// ============================================================
|
|
5
|
+
//
|
|
6
|
+
// A real JSON Schema so editors (VSCode, etc.) give autocomplete and
|
|
7
|
+
// validation while you edit notsleep.json — the way OpenCode's
|
|
8
|
+
// https://opencode.ai/config.json does. `notsleep schema` writes this to disk
|
|
9
|
+
// and `notsleep init` points the config's "$schema" at it, so it works fully
|
|
10
|
+
// offline (no dependency on a hosted URL).
|
|
11
|
+
// ============================================================
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.DEFAULT_SCHEMA_FILENAME = exports.NOTSLEEP_JSON_SCHEMA = void 0;
|
|
47
|
+
exports.schemaJson = schemaJson;
|
|
48
|
+
exports.writeSchemaFile = writeSchemaFile;
|
|
49
|
+
const fs = __importStar(require("fs"));
|
|
50
|
+
const path = __importStar(require("path"));
|
|
51
|
+
const providerModelBlock = {
|
|
52
|
+
type: 'object',
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
properties: {
|
|
55
|
+
apiKey: { type: 'string', description: 'API key, or a {env:VAR} reference.' },
|
|
56
|
+
model: { type: 'string', description: 'Default model id for this provider.' },
|
|
57
|
+
baseURL: { type: 'string', description: 'Custom API base URL (Azure, proxy, local server, ...).' },
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
/** The JSON Schema object describing a notsleep.json file. */
|
|
61
|
+
exports.NOTSLEEP_JSON_SCHEMA = {
|
|
62
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
63
|
+
title: 'NotSleep configuration',
|
|
64
|
+
description: 'Configuration for the NotSleep long-horizon autonomous agent.',
|
|
65
|
+
type: 'object',
|
|
66
|
+
additionalProperties: true,
|
|
67
|
+
properties: {
|
|
68
|
+
$schema: { type: 'string' },
|
|
69
|
+
model: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: 'Unified "provider/model" selector, e.g. "anthropic/claude-sonnet-4-20250514" or "groq/llama-3.3-70b-versatile".',
|
|
72
|
+
},
|
|
73
|
+
small_model: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description: 'Cheaper model for internal calls (summarization, task generation). A provider/model ref, or a bare model id that reuses the primary provider credentials.',
|
|
76
|
+
},
|
|
77
|
+
smallModel: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'Alias for small_model.',
|
|
80
|
+
},
|
|
81
|
+
providers: {
|
|
82
|
+
type: 'object',
|
|
83
|
+
description: 'Named provider registry. Overlays the built-in providers; give just an apiKey for a known one, or a full { type, baseURL, apiKey } for a new one.',
|
|
84
|
+
additionalProperties: {
|
|
85
|
+
type: 'object',
|
|
86
|
+
additionalProperties: false,
|
|
87
|
+
properties: {
|
|
88
|
+
type: { enum: ['openai', 'anthropic'], description: 'Protocol. Default: openai (OpenAI-compatible).' },
|
|
89
|
+
baseURL: { type: 'string' },
|
|
90
|
+
apiKey: { type: 'string' },
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
provider: { enum: ['openai', 'anthropic'], description: 'Legacy active provider (use `model` instead for the registry).' },
|
|
95
|
+
openai: providerModelBlock,
|
|
96
|
+
anthropic: providerModelBlock,
|
|
97
|
+
systemPrompt: { type: 'string', description: 'System prompt. Supports {file:./path} references.' },
|
|
98
|
+
systemPromptFile: { type: 'string', description: 'Path to a file containing the system prompt (relative to this config).' },
|
|
99
|
+
instructions: {
|
|
100
|
+
type: 'array',
|
|
101
|
+
items: { type: 'string' },
|
|
102
|
+
description: 'Instruction files appended to the system prompt (relative to this config). AGENTS.md / NOTSLEEP.md in the project root are auto-loaded too.',
|
|
103
|
+
},
|
|
104
|
+
maxIterations: { type: 'integer', minimum: 0, description: '0 = unlimited.' },
|
|
105
|
+
maxIterationsPerTask: { type: 'integer', minimum: 0, description: 'Auto-advance to the next task after N iterations. 0 = no cap.' },
|
|
106
|
+
contextWindowLimit: { type: 'integer', minimum: 0, description: '0 = auto-detect from the model (live via models.dev, then static table).' },
|
|
107
|
+
summarizeThreshold: { type: 'number', minimum: 0, maximum: 1, description: 'Fraction of the window at which to summarize (e.g. 0.75).' },
|
|
108
|
+
maxRetries: { type: 'integer', minimum: 0 },
|
|
109
|
+
retryBaseDelayMs: { type: 'integer', minimum: 0 },
|
|
110
|
+
toolTimeoutMs: { type: 'integer', minimum: 0 },
|
|
111
|
+
checkpointDir: { type: 'string' },
|
|
112
|
+
logDir: { type: 'string' },
|
|
113
|
+
continuous: { type: 'boolean', description: 'Keep picking up new tasks until the queue is empty or you stop it.' },
|
|
114
|
+
stopFile: { type: 'string', description: 'Creating this file signals the agent to stop.' },
|
|
115
|
+
maxCostUsd: { type: 'number', minimum: 0, description: 'Stop when estimated cost exceeds this USD budget.' },
|
|
116
|
+
autoCommit: { type: 'boolean', description: 'Create a local git commit after each completed task (never pushes).' },
|
|
117
|
+
dashboard: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
additionalProperties: false,
|
|
120
|
+
properties: {
|
|
121
|
+
enabled: { type: 'boolean' },
|
|
122
|
+
port: { type: 'integer' },
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
customTools: {
|
|
126
|
+
type: 'array',
|
|
127
|
+
description: 'User-defined shell-command tools the agent can call.',
|
|
128
|
+
items: {
|
|
129
|
+
type: 'object',
|
|
130
|
+
additionalProperties: false,
|
|
131
|
+
required: ['name', 'description', 'command'],
|
|
132
|
+
properties: {
|
|
133
|
+
name: { type: 'string' },
|
|
134
|
+
description: { type: 'string' },
|
|
135
|
+
command: { type: 'string', description: 'Shell command template; {param} placeholders are substituted (shell-escaped).' },
|
|
136
|
+
cwd: { type: 'string' },
|
|
137
|
+
parameters: {
|
|
138
|
+
type: 'object',
|
|
139
|
+
additionalProperties: {
|
|
140
|
+
type: 'object',
|
|
141
|
+
additionalProperties: false,
|
|
142
|
+
properties: {
|
|
143
|
+
description: { type: 'string' },
|
|
144
|
+
required: { type: 'boolean' },
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
/** Serialize the schema to pretty JSON. */
|
|
154
|
+
function schemaJson() {
|
|
155
|
+
return JSON.stringify(exports.NOTSLEEP_JSON_SCHEMA, null, 2) + '\n';
|
|
156
|
+
}
|
|
157
|
+
/** Write the schema file, creating parent directories as needed. Returns the path. */
|
|
158
|
+
function writeSchemaFile(filePath) {
|
|
159
|
+
const abs = path.resolve(filePath);
|
|
160
|
+
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
|
161
|
+
fs.writeFileSync(abs, schemaJson(), 'utf-8');
|
|
162
|
+
return abs;
|
|
163
|
+
}
|
|
164
|
+
/** Default filename for the generated schema, written beside the config file. */
|
|
165
|
+
exports.DEFAULT_SCHEMA_FILENAME = 'notsleep.schema.json';
|
|
166
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,2CAA2C;AAC3C,+DAA+D;AAC/D,EAAE;AACF,qEAAqE;AACrE,+DAA+D;AAC/D,8EAA8E;AAC9E,6EAA6E;AAC7E,2CAA2C;AAC3C,+DAA+D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqH/D,gCAEC;AAGD,0CAKC;AA7HD,uCAAyB;AACzB,2CAA6B;AAE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AS,CAAC,4BAAoB,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;AAC9D,CAAC;AAED,sFAAsF;AACtF,SAAgB,eAAe,CAAC,QAAgB;IAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;IAC7C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,iFAAiF;AACpE,QAAA,uBAAuB,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-dashboard.d.ts","sourceRoot":"","sources":["../src/test-dashboard.ts"],"names":[],"mappings":"AAUA,QAAA,MAAQ,eAAe,KAA2B,CAAC;AACnD,QAAA,MAAQ,MAAM,OAAE,QAAQ,KAAwB,CAAC;AACjD,QAAA,MAAM,EAAE,KAAgB,CAAC;AAEzB,iBAAe,IAAI,kBAqMlB"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// NotSleep - Dashboard Test (no API key needed)
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Starts the dashboard server with simulated agent data
|
|
6
|
+
// to preview the UI without needing an actual LLM API key.
|
|
7
|
+
//
|
|
8
|
+
// Run: node dist/test-dashboard.js
|
|
9
|
+
// Open: http://localhost:3120
|
|
10
|
+
// ============================================================
|
|
11
|
+
const { DashboardServer } = require('./dashboard');
|
|
12
|
+
const { Logger, LogLevel } = require('./logger');
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
async function main() {
|
|
15
|
+
// Ensure log dir exists
|
|
16
|
+
fs.mkdirSync('.notsleep/logs', { recursive: true });
|
|
17
|
+
const logger = new Logger('.notsleep/logs', LogLevel.INFO);
|
|
18
|
+
const dashboard = new DashboardServer(3120, logger);
|
|
19
|
+
// Wire logger -> dashboard
|
|
20
|
+
logger.onLog = (entry) => {
|
|
21
|
+
dashboard.pushLog(entry);
|
|
22
|
+
};
|
|
23
|
+
// Handle commands from UI
|
|
24
|
+
dashboard.onCommand = (cmd) => {
|
|
25
|
+
logger.info(`Dashboard command received: ${JSON.stringify(cmd)}`);
|
|
26
|
+
if (cmd.type === 'add_task') {
|
|
27
|
+
// Add to simulated queue
|
|
28
|
+
const task = {
|
|
29
|
+
id: `task-${Date.now()}`,
|
|
30
|
+
description: cmd.description,
|
|
31
|
+
priority: cmd.priority || 'medium',
|
|
32
|
+
status: 'pending',
|
|
33
|
+
addedAt: new Date().toISOString(),
|
|
34
|
+
};
|
|
35
|
+
currentState.taskQueue.push(task);
|
|
36
|
+
dashboard.updateState(currentState);
|
|
37
|
+
}
|
|
38
|
+
if (cmd.type === 'pause') {
|
|
39
|
+
currentState.status = 'paused';
|
|
40
|
+
currentState.paused = true;
|
|
41
|
+
dashboard.updateState(currentState);
|
|
42
|
+
}
|
|
43
|
+
if (cmd.type === 'resume') {
|
|
44
|
+
currentState.status = 'running';
|
|
45
|
+
currentState.paused = false;
|
|
46
|
+
dashboard.updateState(currentState);
|
|
47
|
+
}
|
|
48
|
+
if (cmd.type === 'stop') {
|
|
49
|
+
currentState.status = 'stopped';
|
|
50
|
+
dashboard.updateState(currentState);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
await dashboard.start();
|
|
54
|
+
console.log('\n ============================================');
|
|
55
|
+
console.log(' NotSleep Dashboard Test Server');
|
|
56
|
+
console.log(' Open: http://localhost:3120');
|
|
57
|
+
console.log(' Press Ctrl+C to stop');
|
|
58
|
+
console.log(' ============================================\n');
|
|
59
|
+
// Simulated state
|
|
60
|
+
const currentState = {
|
|
61
|
+
status: 'running',
|
|
62
|
+
currentTask: 'Build a REST API with authentication, database integration, and comprehensive tests',
|
|
63
|
+
taskQueue: [
|
|
64
|
+
{
|
|
65
|
+
id: 'task-1',
|
|
66
|
+
description: 'Build a REST API with authentication, database integration, and comprehensive tests',
|
|
67
|
+
priority: 'high',
|
|
68
|
+
status: 'in_progress',
|
|
69
|
+
addedAt: new Date().toISOString(),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: 'task-2',
|
|
73
|
+
description: 'Write unit tests for all API endpoints',
|
|
74
|
+
priority: 'medium',
|
|
75
|
+
status: 'pending',
|
|
76
|
+
addedAt: new Date().toISOString(),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'task-3',
|
|
80
|
+
description: 'Add API documentation with Swagger/OpenAPI',
|
|
81
|
+
priority: 'low',
|
|
82
|
+
status: 'pending',
|
|
83
|
+
addedAt: new Date().toISOString(),
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 'task-0',
|
|
87
|
+
description: 'Set up project structure and install dependencies',
|
|
88
|
+
priority: 'high',
|
|
89
|
+
status: 'completed',
|
|
90
|
+
addedAt: new Date(Date.now() - 300000).toISOString(),
|
|
91
|
+
completedAt: new Date(Date.now() - 120000).toISOString(),
|
|
92
|
+
summary: 'Created Express app with TypeScript, installed all deps, set up folder structure',
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
stats: {
|
|
96
|
+
startTime: Date.now() - 120000,
|
|
97
|
+
totalIterations: 0,
|
|
98
|
+
totalTokensUsed: 0,
|
|
99
|
+
totalToolCalls: 0,
|
|
100
|
+
errors: 0,
|
|
101
|
+
contextResets: 0,
|
|
102
|
+
tasksCompleted: 1,
|
|
103
|
+
tasksFailed: 0,
|
|
104
|
+
totalCostUsd: 0,
|
|
105
|
+
},
|
|
106
|
+
provider: 'limitrouter',
|
|
107
|
+
model: 'claude-opus-4-6',
|
|
108
|
+
smallModel: 'claude-haiku-4.5',
|
|
109
|
+
contextLimitSource: 'models.dev',
|
|
110
|
+
continuous: true,
|
|
111
|
+
recentLogs: [],
|
|
112
|
+
paused: false,
|
|
113
|
+
contextUsage: 0,
|
|
114
|
+
contextLimit: 900000,
|
|
115
|
+
maxIterations: 0,
|
|
116
|
+
};
|
|
117
|
+
dashboard.updateState(currentState);
|
|
118
|
+
// Simulate agent activity
|
|
119
|
+
const logMessages = [
|
|
120
|
+
{ level: 'INFO', msg: 'Starting agent loop for task: Build a REST API...' },
|
|
121
|
+
{ level: 'INFO', msg: 'Provider: openai | Model: gpt-4o' },
|
|
122
|
+
{ level: 'INFO', msg: 'Mode: CONTINUOUS (runs until you wake up)' },
|
|
123
|
+
{ level: 'AGENT', msg: 'I\'ll start by setting up the Express server with TypeScript configuration.' },
|
|
124
|
+
{ level: 'TOOL:shell', msg: '$ npm init -y && npm install express typescript @types/express' },
|
|
125
|
+
{ level: 'TOOL:write_file', msg: 'src/server.ts' },
|
|
126
|
+
{ level: 'AGENT', msg: 'Express server created. Now adding authentication middleware with JWT.' },
|
|
127
|
+
{ level: 'TOOL:shell', msg: '$ npm install jsonwebtoken bcryptjs @types/jsonwebtoken' },
|
|
128
|
+
{ level: 'TOOL:write_file', msg: 'src/middleware/auth.ts' },
|
|
129
|
+
{ level: 'TOOL:write_file', msg: 'src/routes/auth.ts' },
|
|
130
|
+
{ level: 'AGENT', msg: 'Auth routes done. Adding user registration and login endpoints.' },
|
|
131
|
+
{ level: 'TOOL:shell', msg: '$ npm install prisma @prisma/client' },
|
|
132
|
+
{ level: 'AGENT', msg: 'Database integration with Prisma ORM set up. Creating schema...' },
|
|
133
|
+
{ level: 'TOOL:write_file', msg: 'prisma/schema.prisma' },
|
|
134
|
+
{ level: 'TOOL:shell', msg: '$ npx prisma generate' },
|
|
135
|
+
{ level: 'AGENT', msg: 'Schema generated. Now implementing CRUD endpoints for users resource.' },
|
|
136
|
+
{ level: 'WARN', msg: 'Rate limit approaching, slowing down requests...' },
|
|
137
|
+
{ level: 'TOOL:write_file', msg: 'src/routes/users.ts' },
|
|
138
|
+
{ level: 'AGENT', msg: 'User CRUD complete. Running build to verify no type errors.' },
|
|
139
|
+
{ level: 'TOOL:shell', msg: '$ npm run build' },
|
|
140
|
+
{ level: 'INFO', msg: 'Build successful. Moving to error handling middleware.' },
|
|
141
|
+
{ level: 'TOOL:write_file', msg: 'src/middleware/errorHandler.ts' },
|
|
142
|
+
{ level: 'AGENT', msg: 'Error handling added. Now writing integration tests with Jest.' },
|
|
143
|
+
{ level: 'TOOL:shell', msg: '$ npm install --save-dev jest ts-jest @types/jest supertest' },
|
|
144
|
+
{ level: 'TOOL:write_file', msg: 'src/__tests__/auth.test.ts' },
|
|
145
|
+
{ level: 'TOOL:shell', msg: '$ npm test' },
|
|
146
|
+
{ level: 'AGENT', msg: 'All 12 tests passing! Adding rate limiting and input validation.' },
|
|
147
|
+
{ level: 'ERROR', msg: 'Test for edge case failed: empty email should return 400' },
|
|
148
|
+
{ level: 'AGENT', msg: 'Fixing validation - adding express-validator for input sanitization.' },
|
|
149
|
+
{ level: 'TOOL:shell', msg: '$ npm test -- --verbose' },
|
|
150
|
+
{ level: 'AGENT', msg: 'All 15 tests passing now. Task is nearly complete.' },
|
|
151
|
+
];
|
|
152
|
+
let logIndex = 0;
|
|
153
|
+
let iteration = 24;
|
|
154
|
+
const interval = setInterval(() => {
|
|
155
|
+
if (currentState.status === 'paused' || currentState.status === 'stopped')
|
|
156
|
+
return;
|
|
157
|
+
iteration++;
|
|
158
|
+
const tokens = Math.floor(iteration * 2847);
|
|
159
|
+
const tools = Math.floor(iteration * 1.8);
|
|
160
|
+
currentState.stats.totalIterations = iteration;
|
|
161
|
+
currentState.stats.totalTokensUsed = tokens;
|
|
162
|
+
currentState.stats.totalToolCalls = tools;
|
|
163
|
+
// Rough cost estimate (Opus-ish input rate) so the cost + $/hr tiles move.
|
|
164
|
+
currentState.stats.totalCostUsd = (tokens / 1_000_000) * 15;
|
|
165
|
+
// Context window fills up over ~30 iterations, then a summarize resets it.
|
|
166
|
+
currentState.contextUsage = Math.min(((iteration % 30) / 30) * 0.98, 0.98);
|
|
167
|
+
if (iteration % 30 === 0) {
|
|
168
|
+
currentState.stats.contextResets++;
|
|
169
|
+
}
|
|
170
|
+
// Cycle through log messages
|
|
171
|
+
if (logIndex < logMessages.length) {
|
|
172
|
+
const log = logMessages[logIndex];
|
|
173
|
+
if (log.level === 'AGENT')
|
|
174
|
+
logger.agent(log.msg);
|
|
175
|
+
else if (log.level === 'WARN')
|
|
176
|
+
logger.warn(log.msg);
|
|
177
|
+
else if (log.level === 'ERROR') {
|
|
178
|
+
logger.error(log.msg);
|
|
179
|
+
currentState.stats.errors++;
|
|
180
|
+
}
|
|
181
|
+
else if (log.level.startsWith('TOOL:'))
|
|
182
|
+
logger.tool(log.level.replace('TOOL:', ''), log.msg);
|
|
183
|
+
else
|
|
184
|
+
logger.info(log.msg);
|
|
185
|
+
logIndex++;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
// Loop back
|
|
189
|
+
logIndex = 3;
|
|
190
|
+
}
|
|
191
|
+
dashboard.updateState(currentState);
|
|
192
|
+
}, 2000);
|
|
193
|
+
// Keep running until Ctrl+C
|
|
194
|
+
process.on('SIGINT', async () => {
|
|
195
|
+
clearInterval(interval);
|
|
196
|
+
await dashboard.stop();
|
|
197
|
+
console.log('\nDashboard stopped.');
|
|
198
|
+
process.exit(0);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
main().catch(console.error);
|
|
202
|
+
//# sourceMappingURL=test-dashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-dashboard.js","sourceRoot":"","sources":["../src/test-dashboard.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,gDAAgD;AAChD,+DAA+D;AAC/D,wDAAwD;AACxD,2DAA2D;AAC3D,EAAE;AACF,mCAAmC;AACnC,8BAA8B;AAC9B,+DAA+D;AAE/D,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACnD,MAAM,EAAE,MAA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,CAAC;QAED,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC,EAAE,IAAI,CAAC,CAAC;IAET,4BAA4B;IAC5B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC9B,aAAa,CAAC,QAAQ,CAAC,CAAC;QACxB,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ToolDefinition, QueuedTask, CustomToolConfig } from './types';
|
|
2
|
+
import { Logger } from './logger';
|
|
3
|
+
/**
|
|
4
|
+
* Build ToolDefinitions from user-declared custom tools (notsleep.json).
|
|
5
|
+
* Each runs its shell `command`, substituting {param} placeholders with
|
|
6
|
+
* shell-escaped argument values. Invalid definitions are skipped with a warning.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createCustomTools(defs: CustomToolConfig[] | undefined, logger: Logger, toolTimeoutMs: number): ToolDefinition[];
|
|
9
|
+
export interface SearchResult {
|
|
10
|
+
title: string;
|
|
11
|
+
url: string;
|
|
12
|
+
snippet: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Parse DuckDuckGo's HTML results page into structured results. Kept as a
|
|
16
|
+
* pure, exported function so it can be unit-tested without a network call.
|
|
17
|
+
* DDG wraps each result link in `<a class="result__a" href="...">title</a>`
|
|
18
|
+
* and the snippet in `<a class="result__snippet">...</a>`. Redirect hrefs of
|
|
19
|
+
* the form `//duckduckgo.com/l/?uddg=<encoded real url>` are decoded.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseDuckDuckGoResults(html: string, limit: number): SearchResult[];
|
|
22
|
+
/**
|
|
23
|
+
* Creates the set of built-in tools available to the agent.
|
|
24
|
+
* The taskQueue array is shared with the Agent - tools push to it, agent reads from it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createBuiltinTools(logger: Logger, toolTimeoutMs: number, taskQueue: QueuedTask[], workspaceRoot?: string): ToolDefinition[];
|
|
27
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAiBlC;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,EAAE,GAAG,SAAS,EACpC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACpB,cAAc,EAAE,CA+ElB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,CAuClF;AA8DD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,UAAU,EAAE,EACvB,aAAa,GAAE,MAAsB,GACpC,cAAc,EAAE,CA8+BlB"}
|