@tokentestai/ais 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.
@@ -0,0 +1,27 @@
1
+ interface ProtectShellCommandResult {
2
+ exitCode: number;
3
+ stderr: string;
4
+ stdout: string;
5
+ }
6
+ type ProtectShellRunner = (command: string, args: string[], options: {
7
+ env?: NodeJS.ProcessEnv;
8
+ }) => Promise<ProtectShellCommandResult>;
9
+ interface ProtectRuntimeOptions {
10
+ aisCliPath?: string;
11
+ env?: NodeJS.ProcessEnv;
12
+ homeDir?: string;
13
+ nodePath?: string;
14
+ now?: () => number;
15
+ shellPath?: string;
16
+ shellRunner?: ProtectShellRunner;
17
+ }
18
+
19
+ interface PostinstallRunOptions {
20
+ configPath?: string;
21
+ env?: NodeJS.ProcessEnv;
22
+ protect?: Omit<ProtectRuntimeOptions, 'env'>;
23
+ stderr?: Pick<typeof process.stderr, 'write'>;
24
+ }
25
+ declare function runPostinstallHook(options?: PostinstallRunOptions): Promise<number>;
26
+
27
+ export { type PostinstallRunOptions, runPostinstallHook };
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ loadAutomationState,
4
+ loadConfig,
5
+ saveAutomationState,
6
+ syncProtectRuntime
7
+ } from "./chunk-WVTDLVUU.js";
8
+
9
+ // src/postinstall.ts
10
+ import { resolve } from "path";
11
+ import { fileURLToPath } from "url";
12
+ async function runPostinstallHook(options = {}) {
13
+ const env = options.env ?? process.env;
14
+ const stderr = options.stderr ?? process.stderr;
15
+ if (env.npm_config_global !== "true") {
16
+ return 0;
17
+ }
18
+ try {
19
+ const loadedConfig = await loadConfig(options.configPath);
20
+ const loadedAutomationState = await loadAutomationState(loadedConfig.config.automation.statePath);
21
+ const result = await syncProtectRuntime(loadedConfig.config, loadedAutomationState.state, {
22
+ ...options.protect,
23
+ aisCliPath: options.protect?.aisCliPath ?? fileURLToPath(new URL("./cli.js", import.meta.url)),
24
+ env
25
+ });
26
+ if (result.changed) {
27
+ await saveAutomationState(result.state, loadedAutomationState.path);
28
+ }
29
+ for (const warning of result.warnings) {
30
+ stderr.write(`${warning}
31
+ `);
32
+ }
33
+ for (const error of result.errors) {
34
+ stderr.write(`${error}
35
+ `);
36
+ }
37
+ } catch (error) {
38
+ const message = error instanceof Error ? error.message : String(error);
39
+ stderr.write(`AIS postinstall skipped takeover setup: ${message}
40
+ `);
41
+ }
42
+ return 0;
43
+ }
44
+ var currentFilePath = fileURLToPath(import.meta.url);
45
+ if (process.argv[1] && resolve(process.argv[1]) === currentFilePath) {
46
+ const exitCode = await runPostinstallHook();
47
+ if (exitCode !== 0) {
48
+ process.exit(exitCode);
49
+ }
50
+ }
51
+ export {
52
+ runPostinstallHook
53
+ };
54
+ //# sourceMappingURL=postinstall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/postinstall.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { loadAutomationState, saveAutomationState } from './automation/index.js';\nimport { loadConfig } from './config.js';\nimport { syncProtectRuntime, type ProtectRuntimeOptions } from './protect/index.js';\n\nexport interface PostinstallRunOptions {\n configPath?: string;\n env?: NodeJS.ProcessEnv;\n protect?: Omit<ProtectRuntimeOptions, 'env'>;\n stderr?: Pick<typeof process.stderr, 'write'>;\n}\n\nexport async function runPostinstallHook(options: PostinstallRunOptions = {}): Promise<number> {\n const env = options.env ?? process.env;\n const stderr = options.stderr ?? process.stderr;\n\n if (env.npm_config_global !== 'true') {\n return 0;\n }\n\n try {\n const loadedConfig = await loadConfig(options.configPath);\n const loadedAutomationState = await loadAutomationState(loadedConfig.config.automation.statePath);\n const result = await syncProtectRuntime(loadedConfig.config, loadedAutomationState.state, {\n ...options.protect,\n aisCliPath: options.protect?.aisCliPath ?? fileURLToPath(new URL('./cli.js', import.meta.url)),\n env,\n });\n\n if (result.changed) {\n await saveAutomationState(result.state, loadedAutomationState.path);\n }\n\n for (const warning of result.warnings) {\n stderr.write(`${warning}\\n`);\n }\n for (const error of result.errors) {\n stderr.write(`${error}\\n`);\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n stderr.write(`AIS postinstall skipped takeover setup: ${message}\\n`);\n }\n\n return 0;\n}\n\nconst currentFilePath = fileURLToPath(import.meta.url);\nif (process.argv[1] && resolve(process.argv[1]) === currentFilePath) {\n const exitCode = await runPostinstallHook();\n if (exitCode !== 0) {\n process.exit(exitCode);\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAa9B,eAAsB,mBAAmB,UAAiC,CAAC,GAAoB;AAC7F,QAAM,MAAM,QAAQ,OAAO,QAAQ;AACnC,QAAM,SAAS,QAAQ,UAAU,QAAQ;AAEzC,MAAI,IAAI,sBAAsB,QAAQ;AACpC,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,eAAe,MAAM,WAAW,QAAQ,UAAU;AACxD,UAAM,wBAAwB,MAAM,oBAAoB,aAAa,OAAO,WAAW,SAAS;AAChG,UAAM,SAAS,MAAM,mBAAmB,aAAa,QAAQ,sBAAsB,OAAO;AAAA,MACxF,GAAG,QAAQ;AAAA,MACX,YAAY,QAAQ,SAAS,cAAc,cAAc,IAAI,IAAI,YAAY,YAAY,GAAG,CAAC;AAAA,MAC7F;AAAA,IACF,CAAC;AAED,QAAI,OAAO,SAAS;AAClB,YAAM,oBAAoB,OAAO,OAAO,sBAAsB,IAAI;AAAA,IACpE;AAEA,eAAW,WAAW,OAAO,UAAU;AACrC,aAAO,MAAM,GAAG,OAAO;AAAA,CAAI;AAAA,IAC7B;AACA,eAAW,SAAS,OAAO,QAAQ;AACjC,aAAO,MAAM,GAAG,KAAK;AAAA,CAAI;AAAA,IAC3B;AAAA,EACF,SAAS,OAAO;AACd,UAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,WAAO,MAAM,2CAA2C,OAAO;AAAA,CAAI;AAAA,EACrE;AAEA,SAAO;AACT;AAEA,IAAM,kBAAkB,cAAc,YAAY,GAAG;AACrD,IAAI,QAAQ,KAAK,CAAC,KAAK,QAAQ,QAAQ,KAAK,CAAC,CAAC,MAAM,iBAAiB;AACnE,QAAM,WAAW,MAAM,mBAAmB;AAC1C,MAAI,aAAa,GAAG;AAClB,YAAQ,KAAK,QAAQ;AAAA,EACvB;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@tokentestai/ais",
3
+ "version": "0.1.0",
4
+ "description": "AIS adds a local protection layer for AI agents by masking secrets before cloud APIs see them",
5
+ "type": "module",
6
+ "bin": {
7
+ "ais": "dist/cli.js"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/ACanvasHERE/AIS.git"
17
+ },
18
+ "homepage": "https://github.com/ACanvasHERE/AIS#readme",
19
+ "bugs": {
20
+ "url": "https://github.com/ACanvasHERE/AIS/issues"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "LICENSE"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsup",
28
+ "dev": "tsup --watch",
29
+ "lint": "eslint src tsup.config.ts",
30
+ "postinstall": "node dist/postinstall.js",
31
+ "typecheck": "tsc --noEmit",
32
+ "prepublishOnly": "npm run lint && npm run typecheck && npm run build"
33
+ },
34
+ "keywords": [
35
+ "ais",
36
+ "ai",
37
+ "agent",
38
+ "security",
39
+ "privacy",
40
+ "secret",
41
+ "password",
42
+ "claude",
43
+ "codex"
44
+ ],
45
+ "engines": {
46
+ "node": ">=18"
47
+ },
48
+ "license": "MIT",
49
+ "devDependencies": {
50
+ "@eslint/js": "^9.35.0",
51
+ "@types/node": "^25.4.0",
52
+ "eslint": "^9.35.0",
53
+ "globals": "^16.4.0",
54
+ "tsup": "^8.5.1",
55
+ "typescript": "^5.9.3",
56
+ "typescript-eslint": "^8.43.0"
57
+ },
58
+ "dependencies": {
59
+ "keytar": "^7.9.0",
60
+ "node-pty": "^1.1.0"
61
+ }
62
+ }