@intutic/cli 2.1.0 → 2.3.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 +8 -8
- package/dist/cli.d.ts +0 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +492 -21
- package/dist/cli.js.map +1 -1
- package/dist/commands/apiCommand.d.ts +40 -0
- package/dist/commands/apiCommand.d.ts.map +1 -0
- package/dist/commands/apiCommand.js +88 -0
- package/dist/commands/apiCommand.js.map +1 -0
- package/dist/commands/budget.d.ts +4 -0
- package/dist/commands/budget.d.ts.map +1 -1
- package/dist/commands/budget.js +8 -0
- package/dist/commands/budget.js.map +1 -1
- package/dist/commands/compliance.d.ts +122 -0
- package/dist/commands/compliance.d.ts.map +1 -0
- package/dist/commands/compliance.js +278 -0
- package/dist/commands/compliance.js.map +1 -0
- package/dist/commands/connect.d.ts +26 -1
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +222 -86
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/credentials.d.ts +1 -1
- package/dist/commands/credentials.js +1 -1
- package/dist/commands/decision.d.ts +4 -4
- package/dist/commands/decision.js +4 -4
- package/dist/commands/disconnect.d.ts +29 -0
- package/dist/commands/disconnect.d.ts.map +1 -0
- package/dist/commands/disconnect.js +266 -0
- package/dist/commands/disconnect.js.map +1 -0
- package/dist/commands/doctor.d.ts +0 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +0 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/enforce.d.ts +1 -1
- package/dist/commands/enforce.js +1 -1
- package/dist/commands/enterprise.d.ts +3 -2
- package/dist/commands/enterprise.d.ts.map +1 -1
- package/dist/commands/enterprise.js +11 -3
- package/dist/commands/enterprise.js.map +1 -1
- package/dist/commands/env.d.ts +1 -1
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +3 -8
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/exec.d.ts +2 -3
- package/dist/commands/exec.d.ts.map +1 -1
- package/dist/commands/exec.js +4 -5
- package/dist/commands/exec.js.map +1 -1
- package/dist/commands/gateLiveness.d.ts +15 -0
- package/dist/commands/gateLiveness.d.ts.map +1 -0
- package/dist/commands/gateLiveness.js +34 -0
- package/dist/commands/gateLiveness.js.map +1 -0
- package/dist/commands/gateway.d.ts +16 -4
- package/dist/commands/gateway.d.ts.map +1 -1
- package/dist/commands/gateway.js +47 -6
- package/dist/commands/gateway.js.map +1 -1
- package/dist/commands/github.d.ts +20 -0
- package/dist/commands/github.d.ts.map +1 -0
- package/dist/commands/github.js +41 -0
- package/dist/commands/github.js.map +1 -0
- package/dist/commands/guardrails.d.ts +28 -2
- package/dist/commands/guardrails.d.ts.map +1 -1
- package/dist/commands/guardrails.js +233 -24
- package/dist/commands/guardrails.js.map +1 -1
- package/dist/commands/init.d.ts +1 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +3 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install-daemon.d.ts +1 -1
- package/dist/commands/install-daemon.js +2 -2
- package/dist/commands/integrity.d.ts +10 -2
- package/dist/commands/integrity.d.ts.map +1 -1
- package/dist/commands/integrity.js +10 -3
- package/dist/commands/integrity.js.map +1 -1
- package/dist/commands/inventory.d.ts +60 -0
- package/dist/commands/inventory.d.ts.map +1 -0
- package/dist/commands/inventory.js +141 -0
- package/dist/commands/inventory.js.map +1 -0
- package/dist/commands/judge.d.ts +1 -1
- package/dist/commands/judge.js +2 -2
- package/dist/commands/judge.js.map +1 -1
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +0 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts +0 -1
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/logout.js +0 -1
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/mcp.d.ts +31 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +65 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/notifications.d.ts +54 -0
- package/dist/commands/notifications.d.ts.map +1 -0
- package/dist/commands/notifications.js +151 -0
- package/dist/commands/notifications.js.map +1 -0
- package/dist/commands/org.d.ts +3 -3
- package/dist/commands/org.js +3 -3
- package/dist/commands/policy.d.ts +6 -1
- package/dist/commands/policy.d.ts.map +1 -1
- package/dist/commands/policy.js +77 -37
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/predict-cost.d.ts +1 -2
- package/dist/commands/predict-cost.d.ts.map +1 -1
- package/dist/commands/predict-cost.js +1 -4
- package/dist/commands/predict-cost.js.map +1 -1
- package/dist/commands/rollback.d.ts.map +1 -1
- package/dist/commands/rollback.js +3 -1
- package/dist/commands/rollback.js.map +1 -1
- package/dist/commands/routing.d.ts +1 -1
- package/dist/commands/routing.js +1 -1
- package/dist/commands/rules.d.ts +74 -0
- package/dist/commands/rules.d.ts.map +1 -0
- package/dist/commands/rules.js +283 -0
- package/dist/commands/rules.js.map +1 -0
- package/dist/commands/settings.d.ts +43 -0
- package/dist/commands/settings.d.ts.map +1 -0
- package/dist/commands/settings.js +108 -0
- package/dist/commands/settings.js.map +1 -0
- package/dist/commands/setup.d.ts +1 -1
- package/dist/commands/setup.js +1 -1
- package/dist/commands/siem.d.ts +53 -0
- package/dist/commands/siem.d.ts.map +1 -0
- package/dist/commands/siem.js +132 -0
- package/dist/commands/siem.js.map +1 -0
- package/dist/commands/skill.d.ts +5 -5
- package/dist/commands/skill.js +7 -7
- package/dist/commands/skill.js.map +1 -1
- package/dist/commands/status.d.ts +0 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +2 -3
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/syncContext.d.ts +0 -1
- package/dist/commands/syncContext.d.ts.map +1 -1
- package/dist/commands/syncContext.js +0 -1
- package/dist/commands/syncContext.js.map +1 -1
- package/dist/commands/team.d.ts +2 -2
- package/dist/commands/team.js +2 -2
- package/dist/commands/traces.d.ts +0 -3
- package/dist/commands/traces.d.ts.map +1 -1
- package/dist/commands/traces.js +0 -3
- package/dist/commands/traces.js.map +1 -1
- package/dist/commands/usage.d.ts +41 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +129 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/whoami.d.ts +0 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +0 -1
- package/dist/commands/whoami.js.map +1 -1
- package/dist/config/keychain.d.ts +0 -1
- package/dist/config/keychain.d.ts.map +1 -1
- package/dist/config/keychain.js +0 -1
- package/dist/config/keychain.js.map +1 -1
- package/dist/config/paths.d.ts +0 -1
- package/dist/config/paths.d.ts.map +1 -1
- package/dist/config/paths.js +0 -1
- package/dist/config/paths.js.map +1 -1
- package/dist/config/store.d.ts +0 -1
- package/dist/config/store.d.ts.map +1 -1
- package/dist/config/store.js +0 -1
- package/dist/config/store.js.map +1 -1
- package/dist/harness/ag2.d.ts +1 -1
- package/dist/harness/ag2.js +1 -1
- package/dist/harness/agentFramework.d.ts +1 -1
- package/dist/harness/agentFramework.js +1 -1
- package/dist/harness/agenticOrchestrator.d.ts +4 -6
- package/dist/harness/agenticOrchestrator.d.ts.map +1 -1
- package/dist/harness/agenticOrchestrator.js +5 -7
- package/dist/harness/agenticOrchestrator.js.map +1 -1
- package/dist/harness/agentsMd.d.ts +24 -0
- package/dist/harness/agentsMd.d.ts.map +1 -0
- package/dist/harness/agentsMd.js +28 -0
- package/dist/harness/agentsMd.js.map +1 -0
- package/dist/harness/aider.d.ts +3 -1
- package/dist/harness/aider.d.ts.map +1 -1
- package/dist/harness/aider.js +9 -7
- package/dist/harness/aider.js.map +1 -1
- package/dist/harness/antigravity.d.ts +23 -5
- package/dist/harness/antigravity.d.ts.map +1 -1
- package/dist/harness/antigravity.js +45 -54
- package/dist/harness/antigravity.js.map +1 -1
- package/dist/harness/autogen.d.ts +1 -1
- package/dist/harness/autogen.js +2 -2
- package/dist/harness/autogen.js.map +1 -1
- package/dist/harness/claudeCode.d.ts +22 -1
- package/dist/harness/claudeCode.d.ts.map +1 -1
- package/dist/harness/claudeCode.js +47 -3
- package/dist/harness/claudeCode.js.map +1 -1
- package/dist/harness/cline.d.ts.map +1 -1
- package/dist/harness/cline.js +16 -24
- package/dist/harness/cline.js.map +1 -1
- package/dist/harness/codex.d.ts +6 -1
- package/dist/harness/codex.d.ts.map +1 -1
- package/dist/harness/codex.js +26 -28
- package/dist/harness/codex.js.map +1 -1
- package/dist/harness/continue.d.ts +10 -4
- package/dist/harness/continue.d.ts.map +1 -1
- package/dist/harness/continue.js +22 -22
- package/dist/harness/continue.js.map +1 -1
- package/dist/harness/cursor.d.ts +5 -2
- package/dist/harness/cursor.d.ts.map +1 -1
- package/dist/harness/cursor.js +19 -27
- package/dist/harness/cursor.js.map +1 -1
- package/dist/harness/detector.d.ts +0 -1
- package/dist/harness/detector.d.ts.map +1 -1
- package/dist/harness/detector.js +0 -1
- package/dist/harness/detector.js.map +1 -1
- package/dist/harness/dsh.d.ts +5 -3
- package/dist/harness/dsh.d.ts.map +1 -1
- package/dist/harness/dsh.js +17 -29
- package/dist/harness/dsh.js.map +1 -1
- package/dist/harness/eve.d.ts +3 -4
- package/dist/harness/eve.d.ts.map +1 -1
- package/dist/harness/eve.js +3 -4
- package/dist/harness/eve.js.map +1 -1
- package/dist/harness/githubCopilot.d.ts +4 -1
- package/dist/harness/githubCopilot.d.ts.map +1 -1
- package/dist/harness/githubCopilot.js +13 -24
- package/dist/harness/githubCopilot.js.map +1 -1
- package/dist/harness/goose.d.ts +7 -3
- package/dist/harness/goose.d.ts.map +1 -1
- package/dist/harness/goose.js +18 -21
- package/dist/harness/goose.js.map +1 -1
- package/dist/harness/grok.d.ts +2 -2
- package/dist/harness/grok.d.ts.map +1 -1
- package/dist/harness/grok.js +15 -28
- package/dist/harness/grok.js.map +1 -1
- package/dist/harness/hermes.d.ts +6 -0
- package/dist/harness/hermes.d.ts.map +1 -1
- package/dist/harness/hermes.js +17 -16
- package/dist/harness/hermes.js.map +1 -1
- package/dist/harness/jsSdkGatedAdapter.d.ts.map +1 -1
- package/dist/harness/jsSdkGatedAdapter.js +4 -6
- package/dist/harness/jsSdkGatedAdapter.js.map +1 -1
- package/dist/harness/langgraph.d.ts.map +1 -1
- package/dist/harness/langgraph.js +4 -6
- package/dist/harness/langgraph.js.map +1 -1
- package/dist/harness/muse.d.ts +3 -7
- package/dist/harness/muse.d.ts.map +1 -1
- package/dist/harness/muse.js +17 -39
- package/dist/harness/muse.js.map +1 -1
- package/dist/harness/n8n.d.ts +13 -7
- package/dist/harness/n8n.d.ts.map +1 -1
- package/dist/harness/n8n.js +21 -127
- package/dist/harness/n8n.js.map +1 -1
- package/dist/harness/openWebUI.d.ts.map +1 -1
- package/dist/harness/openWebUI.js +5 -4
- package/dist/harness/openWebUI.js.map +1 -1
- package/dist/harness/openaiAgents.d.ts +1 -1
- package/dist/harness/openaiAgents.d.ts.map +1 -1
- package/dist/harness/openaiAgents.js +6 -3
- package/dist/harness/openaiAgents.js.map +1 -1
- package/dist/harness/openclaw.d.ts +8 -0
- package/dist/harness/openclaw.d.ts.map +1 -1
- package/dist/harness/openclaw.js +27 -12
- package/dist/harness/openclaw.js.map +1 -1
- package/dist/harness/opencode.d.ts +4 -5
- package/dist/harness/opencode.d.ts.map +1 -1
- package/dist/harness/opencode.js +17 -34
- package/dist/harness/opencode.js.map +1 -1
- package/dist/harness/openhands.d.ts +9 -3
- package/dist/harness/openhands.d.ts.map +1 -1
- package/dist/harness/openhands.js +43 -25
- package/dist/harness/openhands.js.map +1 -1
- package/dist/harness/pi.d.ts +7 -2
- package/dist/harness/pi.d.ts.map +1 -1
- package/dist/harness/pi.js +19 -18
- package/dist/harness/pi.js.map +1 -1
- package/dist/harness/rooCode.d.ts +12 -5
- package/dist/harness/rooCode.d.ts.map +1 -1
- package/dist/harness/rooCode.js +25 -43
- package/dist/harness/rooCode.js.map +1 -1
- package/dist/harness/rulesFiles.d.ts +53 -0
- package/dist/harness/rulesFiles.d.ts.map +1 -0
- package/dist/harness/rulesFiles.js +106 -0
- package/dist/harness/rulesFiles.js.map +1 -0
- package/dist/harness/sdkGatedAdapter.d.ts.map +1 -1
- package/dist/harness/sdkGatedAdapter.js +4 -6
- package/dist/harness/sdkGatedAdapter.js.map +1 -1
- package/dist/harness/smolagents.d.ts +2 -2
- package/dist/harness/smolagents.js +3 -3
- package/dist/harness/smolagents.js.map +1 -1
- package/dist/harness/types.d.ts +20 -6
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js +1 -95
- package/dist/harness/types.js.map +1 -1
- package/dist/harness/windsurf.d.ts +7 -2
- package/dist/harness/windsurf.d.ts.map +1 -1
- package/dist/harness/windsurf.js +22 -29
- package/dist/harness/windsurf.js.map +1 -1
- package/dist/harness/xirp.d.ts +6 -9
- package/dist/harness/xirp.d.ts.map +1 -1
- package/dist/harness/xirp.js +7 -10
- package/dist/harness/xirp.js.map +1 -1
- package/dist/lib/api.d.ts +27 -1
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +55 -18
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/ciscoScanner.d.ts +1 -1
- package/dist/lib/ciscoScanner.js +1 -1
- package/dist/lib/decisionsLogRefresh.d.ts.map +1 -1
- package/dist/lib/decisionsLogRefresh.js +6 -7
- package/dist/lib/decisionsLogRefresh.js.map +1 -1
- package/dist/lib/deviceReport.d.ts +15 -0
- package/dist/lib/deviceReport.d.ts.map +1 -1
- package/dist/lib/deviceReport.js +30 -0
- package/dist/lib/deviceReport.js.map +1 -1
- package/dist/lib/envInjector.d.ts +16 -6
- package/dist/lib/envInjector.d.ts.map +1 -1
- package/dist/lib/envInjector.js +99 -88
- package/dist/lib/envInjector.js.map +1 -1
- package/dist/lib/gitHooks.d.ts +0 -1
- package/dist/lib/gitHooks.d.ts.map +1 -1
- package/dist/lib/gitHooks.js +8 -9
- package/dist/lib/gitHooks.js.map +1 -1
- package/dist/lib/gracefulShutdown.d.ts +1 -1
- package/dist/lib/gracefulShutdown.js +1 -1
- package/dist/lib/hash.d.ts +0 -1
- package/dist/lib/hash.d.ts.map +1 -1
- package/dist/lib/hash.js +0 -1
- package/dist/lib/hash.js.map +1 -1
- package/dist/lib/inventory.d.ts +47 -0
- package/dist/lib/inventory.d.ts.map +1 -0
- package/dist/lib/inventory.js +106 -0
- package/dist/lib/inventory.js.map +1 -0
- package/dist/lib/logger.d.ts +0 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +0 -1
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/mdmManifest.d.ts +30 -2
- package/dist/lib/mdmManifest.d.ts.map +1 -1
- package/dist/lib/mdmManifest.js +50 -2
- package/dist/lib/mdmManifest.js.map +1 -1
- package/dist/lib/onboarding.d.ts +0 -1
- package/dist/lib/onboarding.d.ts.map +1 -1
- package/dist/lib/onboarding.js +2 -3
- package/dist/lib/onboarding.js.map +1 -1
- package/dist/lib/otelPropagation.d.ts +1 -1
- package/dist/lib/otelPropagation.js +1 -1
- package/dist/lib/policySnapshot.d.ts +3 -1
- package/dist/lib/policySnapshot.d.ts.map +1 -1
- package/dist/lib/policySnapshot.js +15 -5
- package/dist/lib/policySnapshot.js.map +1 -1
- package/dist/lib/process.d.ts +5 -1
- package/dist/lib/process.d.ts.map +1 -1
- package/dist/lib/process.js +13 -4
- package/dist/lib/process.js.map +1 -1
- package/dist/lib/providerProbe.d.ts +2 -2
- package/dist/lib/providerProbe.js +2 -2
- package/dist/lib/sandbox/firecracker.d.ts +3 -3
- package/dist/lib/sandbox/firecracker.js +3 -3
- package/dist/lib/sandbox/index.d.ts +2 -2
- package/dist/lib/sandbox/index.js +2 -2
- package/dist/lib/sandbox/oci.d.ts +1 -1
- package/dist/lib/sandbox/oci.js +1 -1
- package/dist/lib/sandbox/types.d.ts +1 -1
- package/dist/lib/sandbox/types.js +1 -1
- package/dist/lib/sopFrontMatter.d.ts +1 -1
- package/dist/lib/sopFrontMatter.js +1 -1
- package/package.json +6 -5
- package/resources/sandbox/Dockerfile +1 -1
- package/resources/sandbox/entrypoint.sh +4 -4
- package/resources/sandbox/firecracker-launch.sh +1 -1
- package/dist/harness/base.d.ts +0 -20
- package/dist/harness/base.d.ts.map +0 -1
- package/dist/harness/base.js +0 -73
- package/dist/harness/base.js.map +0 -1
package/dist/lib/envInjector.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Environment Variable Injector
|
|
2
|
+
* Environment Variable Injector
|
|
3
3
|
*
|
|
4
4
|
* Injects ANTHROPIC_BASE_URL and OPENAI_BASE_URL as persistent
|
|
5
|
-
*
|
|
5
|
+
* environment variables that new terminals and applications pick up, and
|
|
6
|
+
* removes them again.
|
|
6
7
|
*
|
|
7
8
|
* Platform support:
|
|
8
|
-
* macOS: launchctl setenv <KEY> <VALUE>
|
|
9
|
-
* Linux:
|
|
9
|
+
* macOS: launchctl setenv <KEY> <VALUE> (until logout)
|
|
10
|
+
* Linux: /etc/environment when writable (root), else ~/.bashrc
|
|
10
11
|
* Windows: setx <KEY> <VALUE> (user-level, no /M)
|
|
11
12
|
*
|
|
12
|
-
* LLD #30: Multi-Region Preparation, WS-5MR (TD-041)
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
15
15
|
import { execSync } from 'node:child_process';
|
|
@@ -19,80 +19,87 @@ import os from 'node:os';
|
|
|
19
19
|
import { createLogger } from '@intutic/logger';
|
|
20
20
|
const logger = createLogger('envInjector');
|
|
21
21
|
const ENV_VARS = ['ANTHROPIC_BASE_URL', 'OPENAI_BASE_URL'];
|
|
22
|
+
function resolveTarget(t = {}) {
|
|
23
|
+
return {
|
|
24
|
+
platform: t.platform ?? os.platform(),
|
|
25
|
+
bashrc: t.bashrc ?? path.join(os.homedir(), '.bashrc'),
|
|
26
|
+
etcEnvironment: t.etcEnvironment ?? '/etc/environment',
|
|
27
|
+
exec: t.exec ?? ((command) => { execSync(command, { stdio: 'pipe' }); }),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
22
30
|
export class PlatformNotSupportedError extends Error {
|
|
23
31
|
constructor(platform) {
|
|
24
32
|
super(`Platform not supported for env injection: ${platform}`);
|
|
25
33
|
this.name = 'PlatformNotSupportedError';
|
|
26
34
|
}
|
|
27
35
|
}
|
|
28
|
-
export class ElevationRequiredError extends Error {
|
|
29
|
-
constructor(path) {
|
|
30
|
-
super(`System-level write requires root access to ${path}. Falling back to user-level.`);
|
|
31
|
-
this.name = 'ElevationRequiredError';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
36
|
function sanitizeShellValue(val) {
|
|
35
37
|
return val.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/`/g, '\\`').replace(/\$/g, '\\$');
|
|
36
38
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
+
function bashrcMarker(key) {
|
|
40
|
+
return `# intutic-env-${key}`;
|
|
41
|
+
}
|
|
42
|
+
/** `text` without the lines `drop` matches, and otherwise byte for byte. */
|
|
43
|
+
function withoutLines(text, drop) {
|
|
44
|
+
return text.split('\n').filter((l) => !drop(l)).join('\n');
|
|
39
45
|
}
|
|
40
|
-
function
|
|
46
|
+
function isWritable(file) {
|
|
41
47
|
try {
|
|
42
|
-
|
|
48
|
+
fs.accessSync(file, fs.constants.W_OK);
|
|
49
|
+
return true;
|
|
43
50
|
}
|
|
44
51
|
catch {
|
|
45
|
-
|
|
46
|
-
// the key was never set (or the user session has no launchd domain, e.g. over
|
|
47
|
-
// ssh). Both mean "already absent", which is the state the caller asked for.
|
|
52
|
+
return false;
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
|
-
function linuxInjectUser(
|
|
51
|
-
const rcFile = path.join(os.homedir(), '.bashrc');
|
|
52
|
-
const marker = `# intutic-env-${key}`;
|
|
53
|
-
const line = `export ${key}="${sanitizeShellValue(value)}" ${marker}`;
|
|
55
|
+
function linuxInjectUser(bashrc, value) {
|
|
54
56
|
let content = '';
|
|
55
57
|
try {
|
|
56
|
-
content = fs.readFileSync(
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
// A missing ~/.bashrc is the normal first-run case
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
content = fs.readFileSync(bashrc, 'utf8');
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
// A missing ~/.bashrc is the normal first-run case; the write below
|
|
62
|
+
// creates it. Any other read failure must not end in the file being
|
|
63
|
+
// replaced by our two lines.
|
|
64
|
+
if (err.code !== 'ENOENT')
|
|
65
|
+
throw err;
|
|
66
|
+
}
|
|
67
|
+
let next = withoutLines(content, (l) => ENV_VARS.some((key) => l.includes(bashrcMarker(key))));
|
|
68
|
+
if (next !== '' && !next.endsWith('\n'))
|
|
69
|
+
next += '\n';
|
|
70
|
+
for (const key of ENV_VARS)
|
|
71
|
+
next += `export ${key}="${sanitizeShellValue(value)}" ${bashrcMarker(key)}\n`;
|
|
72
|
+
fs.writeFileSync(bashrc, next, { mode: 0o644 });
|
|
70
73
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
/** Removes exactly the marked lines `linuxInjectUser` added. */
|
|
75
|
+
function linuxRemoveUser(bashrc) {
|
|
76
|
+
let content;
|
|
74
77
|
try {
|
|
75
|
-
|
|
76
|
-
const filtered = content.split('\n').filter(l => !l.includes(marker)).join('\n');
|
|
77
|
-
fs.writeFileSync(rcFile, filtered + '\n', { mode: 0o644 });
|
|
78
|
+
content = fs.readFileSync(bashrc, 'utf8');
|
|
78
79
|
}
|
|
79
80
|
catch {
|
|
80
|
-
// Nothing to remove
|
|
81
|
-
// not fail an uninstall: the marker line is inert shell state, so leaving it in
|
|
82
|
-
// place is strictly better than aborting the rest of the removal sequence.
|
|
81
|
+
return; // Nothing to remove.
|
|
83
82
|
}
|
|
83
|
+
const next = withoutLines(content, (l) => ENV_VARS.some((key) => l.includes(bashrcMarker(key))));
|
|
84
|
+
if (next !== content)
|
|
85
|
+
fs.writeFileSync(bashrc, next);
|
|
84
86
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
/**
|
|
88
|
+
* pam_env reads /etc/environment and has no trailing comments, so these
|
|
89
|
+
* lines carry no marker: `KEY=` lines for the two variables are ours to
|
|
90
|
+
* replace and to remove, the same as on the way in.
|
|
91
|
+
*/
|
|
92
|
+
function linuxSetSystem(etcEnvironment, value) {
|
|
93
|
+
const content = fs.readFileSync(etcEnvironment, 'utf8');
|
|
94
|
+
let next = withoutLines(content, (l) => ENV_VARS.some((key) => l.startsWith(`${key}=`)));
|
|
95
|
+
if (value !== null) {
|
|
96
|
+
if (next !== '' && !next.endsWith('\n'))
|
|
97
|
+
next += '\n';
|
|
98
|
+
for (const key of ENV_VARS)
|
|
99
|
+
next += `${key}="${sanitizeShellValue(value)}"\n`;
|
|
95
100
|
}
|
|
101
|
+
if (next !== content)
|
|
102
|
+
fs.writeFileSync(etcEnvironment, next);
|
|
96
103
|
}
|
|
97
104
|
/**
|
|
98
105
|
* Injects ANTHROPIC_BASE_URL and OPENAI_BASE_URL as persistent env vars.
|
|
@@ -100,66 +107,70 @@ function windowsRemove(key) {
|
|
|
100
107
|
* @param proxyUrl - The Intutic proxy URL (e.g. https://proxy.acme.intutic.ai)
|
|
101
108
|
* @returns InjectionResult describing what was done
|
|
102
109
|
*/
|
|
103
|
-
export async function injectBaseUrlEnvVars(proxyUrl) {
|
|
104
|
-
const
|
|
110
|
+
export async function injectBaseUrlEnvVars(proxyUrl, target) {
|
|
111
|
+
const t = resolveTarget(target);
|
|
112
|
+
const platform = t.platform;
|
|
105
113
|
logger.info({ platform, proxyUrl }, 'envInjector.inject_start');
|
|
106
114
|
if (platform === 'darwin') {
|
|
107
115
|
for (const key of ENV_VARS)
|
|
108
|
-
|
|
116
|
+
t.exec(`launchctl setenv ${key} "${sanitizeShellValue(proxyUrl)}"`);
|
|
109
117
|
logger.info({ platform, vars: ENV_VARS }, 'envInjector.macos_launchctl_set');
|
|
110
118
|
return { platform, scope: 'system', vars: [...ENV_VARS], method: 'launchctl setenv' };
|
|
111
119
|
}
|
|
112
120
|
if (platform === 'linux') {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const etcEnv = '/etc/environment';
|
|
117
|
-
// Only attempt if writable (i.e., running as root)
|
|
118
|
-
fs.accessSync(etcEnv, fs.constants.W_OK);
|
|
119
|
-
for (const key of ENV_VARS) {
|
|
120
|
-
let content = fs.readFileSync(etcEnv, 'utf8');
|
|
121
|
-
content = content.split('\n').filter(l => !l.startsWith(`${key}=`)).join('\n');
|
|
122
|
-
content += `\n${key}="${sanitizeShellValue(proxyUrl)}"`;
|
|
123
|
-
fs.writeFileSync(etcEnv, content.trim() + '\n', { mode: 0o644 });
|
|
124
|
-
}
|
|
125
|
-
scope = 'system';
|
|
121
|
+
if (isWritable(t.etcEnvironment)) {
|
|
122
|
+
linuxSetSystem(t.etcEnvironment, proxyUrl);
|
|
126
123
|
logger.info({ platform, vars: ENV_VARS }, 'envInjector.linux_etc_environment_set');
|
|
124
|
+
return { platform, scope: 'system', vars: [...ENV_VARS], method: '/etc/environment' };
|
|
127
125
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
linuxInjectUser(key, proxyUrl);
|
|
132
|
-
logger.info({ platform, vars: ENV_VARS }, 'envInjector.linux_bashrc_set');
|
|
133
|
-
}
|
|
134
|
-
return { platform, scope, vars: [...ENV_VARS], method: scope === 'system' ? '/etc/environment' : '~/.bashrc' };
|
|
126
|
+
linuxInjectUser(t.bashrc, proxyUrl);
|
|
127
|
+
logger.info({ platform, vars: ENV_VARS }, 'envInjector.linux_bashrc_set');
|
|
128
|
+
return { platform, scope: 'user', vars: [...ENV_VARS], method: '~/.bashrc' };
|
|
135
129
|
}
|
|
136
130
|
if (platform === 'win32') {
|
|
137
131
|
for (const key of ENV_VARS)
|
|
138
|
-
|
|
132
|
+
t.exec(`setx ${key} "${sanitizeShellValue(proxyUrl)}"`);
|
|
139
133
|
logger.info({ platform, vars: ENV_VARS }, 'envInjector.windows_setx_set');
|
|
140
134
|
return { platform, scope: 'user', vars: [...ENV_VARS], method: 'setx' };
|
|
141
135
|
}
|
|
142
136
|
throw new PlatformNotSupportedError(platform);
|
|
143
137
|
}
|
|
144
138
|
/**
|
|
145
|
-
* Removes the injected base URL env vars
|
|
139
|
+
* Removes the injected base URL env vars: from wherever `injectBaseUrlEnvVars`
|
|
140
|
+
* can have put them, so a removal is idempotent and complete.
|
|
146
141
|
*/
|
|
147
|
-
export async function removeBaseUrlEnvVars() {
|
|
148
|
-
const
|
|
142
|
+
export async function removeBaseUrlEnvVars(target) {
|
|
143
|
+
const t = resolveTarget(target);
|
|
144
|
+
const platform = t.platform;
|
|
149
145
|
logger.info({ platform }, 'envInjector.remove_start');
|
|
150
146
|
if (platform === 'darwin') {
|
|
151
|
-
for (const key of ENV_VARS)
|
|
152
|
-
|
|
147
|
+
for (const key of ENV_VARS) {
|
|
148
|
+
try {
|
|
149
|
+
t.exec(`launchctl unsetenv ${key}`);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// `launchctl unsetenv` exits non-zero when the key was never set (or the
|
|
153
|
+
// session has no launchd domain, e.g. over ssh): already absent.
|
|
154
|
+
}
|
|
155
|
+
}
|
|
153
156
|
return;
|
|
154
157
|
}
|
|
155
158
|
if (platform === 'linux') {
|
|
156
|
-
|
|
157
|
-
|
|
159
|
+
linuxRemoveUser(t.bashrc);
|
|
160
|
+
// Persist wrote here instead when it ran as root.
|
|
161
|
+
if (isWritable(t.etcEnvironment))
|
|
162
|
+
linuxSetSystem(t.etcEnvironment, null);
|
|
158
163
|
return;
|
|
159
164
|
}
|
|
160
165
|
if (platform === 'win32') {
|
|
161
|
-
for (const key of ENV_VARS)
|
|
162
|
-
|
|
166
|
+
for (const key of ENV_VARS) {
|
|
167
|
+
try {
|
|
168
|
+
t.exec(`reg delete HKCU\\Environment /v ${key} /f`);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// `reg delete` exits 1 when the value is already gone: absence is success.
|
|
172
|
+
}
|
|
173
|
+
}
|
|
163
174
|
return;
|
|
164
175
|
}
|
|
165
176
|
throw new PlatformNotSupportedError(platform);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envInjector.js","sourceRoot":"","sources":["../../src/lib/envInjector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,MAAQ,SAAS,CAAA;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAQ,SAAS,CAAA;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,MAAM,MAAM,GAAG,YAAY,CAAC,aAAa,CAAC,CAAA;AAE1C,MAAM,QAAQ,GAAG,CAAC,oBAAoB,EAAE,iBAAiB,CAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"envInjector.js","sourceRoot":"","sources":["../../src/lib/envInjector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,MAAQ,SAAS,CAAA;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAQ,SAAS,CAAA;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,MAAM,MAAM,GAAG,YAAY,CA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,MAAM,CAAC,CAAA;QACzB,kDAAkD;QAClD,IAAI,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC;YAAE,cAAc,CAAC,CAAC,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;QACxE,OAAM;IACR,CAAC;IACD,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;YAC3B,IAAI,CAAC;gBACH,CAAC,CAAC,IAAI,CAAC,mCAAmC,GAAG,KAAK,CAAC,CAAA;YACrD,CAAC;YAAC,MAAM,CAAC;gBACP,2EAA2E;YAC7E,CAAC;QACH,CAAC;QACD,OAAM;IACR,CAAC;IACD,MAAM,IAAI,yBAAyB,CAAC,QAAQ,CAAC,CAAA;AAC/C,CAAC"}
|
package/dist/lib/gitHooks.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitHooks.d.ts","sourceRoot":"","sources":["../../src/lib/gitHooks.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gitHooks.d.ts","sourceRoot":"","sources":["../../src/lib/gitHooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA8IH;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAkG7E"}
|
package/dist/lib/gitHooks.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Installs post-commit and post-checkout hooks into the workspace's
|
|
5
5
|
* `.git/hooks/` directory to trigger real-time branch/commit tracking.
|
|
6
6
|
*
|
|
7
|
-
* LLD #14 — gitHooks.ts
|
|
8
7
|
* HLD §3.14 — Real-Time State Mirroring (Git hooks context integration)
|
|
9
8
|
*
|
|
10
9
|
* @module
|
|
@@ -20,8 +19,8 @@ const PRE_COMMIT_MARKER = '# Intutic Pre-Commit Secret Scan';
|
|
|
20
19
|
/** Marker line identifying a post-merge hook as ours — same overwrite guard as pre-commit. */
|
|
21
20
|
const POST_MERGE_MARKER = '# Intutic Post-Merge Decisions Log Refresh';
|
|
22
21
|
/**
|
|
23
|
-
* Git-context tracking hook content, shared by post-commit and post-checkout
|
|
24
|
-
*
|
|
22
|
+
* Git-context tracking hook content, shared by post-commit and post-checkout:
|
|
23
|
+
* both fire the same best-effort branch/commit sync, backgrounded
|
|
25
24
|
* and output-suppressed so it never adds latency to the Git command that
|
|
26
25
|
* triggered it.
|
|
27
26
|
*/
|
|
@@ -36,8 +35,8 @@ fi
|
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
38
37
|
* Optional post-merge hook: refreshes the governed decisions log
|
|
39
|
-
* (`.intutic/DECISIONS.md`
|
|
40
|
-
* harness
|
|
38
|
+
* (`.intutic/DECISIONS.md` and the recent entries in each governed
|
|
39
|
+
* harness's instructions file) right after a merge, rather than leaving a developer
|
|
41
40
|
* waiting for the daemon's next ~30s poll. `decisions-log-refresh` itself
|
|
42
41
|
* no-ops (and never errors the shell) when `decisionsLogEnabled` is off or
|
|
43
42
|
* the developer isn't authenticated — see `decisionsLogRefresh.ts`.
|
|
@@ -88,7 +87,7 @@ if [ -n "$findings" ]; then
|
|
|
88
87
|
exit 1
|
|
89
88
|
fi
|
|
90
89
|
|
|
91
|
-
#
|
|
90
|
+
# Warn-only skill-content scan of staged skill-surface additions
|
|
92
91
|
# (.agents/skills/**, .claude/skills/**). Advisory only — this NEVER
|
|
93
92
|
# refuses the commit, unlike the secret scan above. See skillScan.ts's
|
|
94
93
|
# module doc comment for why: the pattern table's false-positive rate
|
|
@@ -106,7 +105,7 @@ exit 0
|
|
|
106
105
|
* Writes one hook file at `<hooksDir>/<name>` unless a foreign (non-Intutic)
|
|
107
106
|
* hook already occupies that path — the shared never-clobber-a-foreign-hook,
|
|
108
107
|
* marker-based-idempotent-rerun behavior every hook `installGitHooks` manages
|
|
109
|
-
* now follows (
|
|
108
|
+
* now follows (previously only pre-commit and post-merge had it).
|
|
110
109
|
*
|
|
111
110
|
* Reads the existing file first: absent, or already carrying `marker` (a
|
|
112
111
|
* previous install of this same hook, safe to overwrite with the current
|
|
@@ -163,7 +162,7 @@ export async function installGitHooks(workspaceRoot) {
|
|
|
163
162
|
try {
|
|
164
163
|
await node_fs.mkdir(hooksDir, { recursive: true });
|
|
165
164
|
// Git-context tracking hooks (post-commit, post-checkout). Marker-
|
|
166
|
-
// disciplined the same way pre-commit and post-merge are below
|
|
165
|
+
// disciplined the same way pre-commit and post-merge are below:
|
|
167
166
|
// never clobber a hook that isn't ours. Until this fix these two
|
|
168
167
|
// overwrote whatever was already at their paths unconditionally — a
|
|
169
168
|
// team's own post-commit/post-checkout script (a notification hook, a
|
|
@@ -188,7 +187,7 @@ export async function installGitHooks(workspaceRoot) {
|
|
|
188
187
|
// Optional post-merge hook (governed decisions log refresh). Marker-
|
|
189
188
|
// disciplined the same way pre-commit is above — never clobber a
|
|
190
189
|
// post-merge hook that isn't ours. Post-commit/post-checkout above now
|
|
191
|
-
// follow this exact same pattern too (
|
|
190
|
+
// follow this exact same pattern too (previously they did not:
|
|
192
191
|
// they unconditionally overwrote whatever was already at those paths,
|
|
193
192
|
// noted as a latent overreach rather than fixed alongside this hook's
|
|
194
193
|
// original addition, since changing existing-install behavior needed its
|
package/dist/lib/gitHooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitHooks.js","sourceRoot":"","sources":["../../src/lib/gitHooks.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gitHooks.js","sourceRoot":"","sources":["../../src/lib/gitHooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,SAAS,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,8FAA8F;A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,CAAC,EAAE,CAAC,CAAA;QAC1F,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
package/dist/lib/hash.d.ts
CHANGED
package/dist/lib/hash.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/lib/hash.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/lib/hash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,qEAAqE;AACrE,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhE;AAED,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
package/dist/lib/hash.js
CHANGED
package/dist/lib/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/lib/hash.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/lib/hash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,qEAAqE;AACrE,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,QAAgB;IAC7C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC3D,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The machine's AI inventory, as `intutic connect` reports it every few
|
|
3
|
+
* minutes: every harness the detection rules find (connected or not), plus
|
|
4
|
+
* what the sync daemon reads about each (`collectDeviceInventory`), sent with
|
|
5
|
+
* the same device fingerprint `intutic enforce` reports under.
|
|
6
|
+
*
|
|
7
|
+
* Detection lives here because the rules are the CLI's harness adapters
|
|
8
|
+
* (`../harness/detector.ts`); the daemon package does not depend on the CLI.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { InventoryDeviceIdentity } from '@intutic/shared-types';
|
|
13
|
+
import { type DetectedHarness } from '@intutic/sync-daemon';
|
|
14
|
+
/** At the default 30-second poll, every five minutes, starting with the first poll. */
|
|
15
|
+
export declare const INVENTORY_EVERY_N_POLLS = 10;
|
|
16
|
+
export declare function shouldReportInventoryThisIteration(pollIteration: number): boolean;
|
|
17
|
+
/** The newest installed version of each extension-based harness, from directory names alone. */
|
|
18
|
+
export declare function vscodeExtensionVersions(home?: string): Promise<Map<string, string>>;
|
|
19
|
+
/**
|
|
20
|
+
* Every harness whose detection rule matches this machine and workspace. A
|
|
21
|
+
* rule that throws counts as not detected: one broken probe must not hide
|
|
22
|
+
* the rest.
|
|
23
|
+
*/
|
|
24
|
+
export declare function detectInstalledHarnesses(workspaceRoot: string, home?: string): Promise<DetectedHarness[]>;
|
|
25
|
+
/**
|
|
26
|
+
* This machine as `/api/v1/devices` knows it: the fingerprint in the local
|
|
27
|
+
* enforcement state when `intutic enforce` or `connect` has written one, so
|
|
28
|
+
* both views name the same device; otherwise the same fingerprint computed now.
|
|
29
|
+
*/
|
|
30
|
+
export declare function inventoryDeviceIdentity(cliVersion: string): Promise<InventoryDeviceIdentity>;
|
|
31
|
+
/**
|
|
32
|
+
* Detects, collects and sends the inventory. Never throws: the sync loop must
|
|
33
|
+
* not stop over a report the next cycle repeats anyway.
|
|
34
|
+
*/
|
|
35
|
+
export declare function reportMachineInventory(opts: {
|
|
36
|
+
controlPlaneUrl: string;
|
|
37
|
+
apiKey: string;
|
|
38
|
+
workspaceRoot: string;
|
|
39
|
+
configured: readonly string[];
|
|
40
|
+
/** Harnesses `intutic disconnect --harness` removed from this machine (config `disconnectedHarnesses`). */
|
|
41
|
+
disconnected?: readonly string[];
|
|
42
|
+
cliVersion: string;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
reported: boolean;
|
|
45
|
+
reason?: string;
|
|
46
|
+
}>;
|
|
47
|
+
//# sourceMappingURL=inventory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory.d.ts","sourceRoot":"","sources":["../../src/lib/inventory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAiD,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAI1G,uFAAuF;AACvF,eAAO,MAAM,uBAAuB,KAAK,CAAA;AAEzC,wBAAgB,kCAAkC,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAEjF;AAaD,gGAAgG;AAChG,wBAAsB,uBAAuB,CAAC,IAAI,GAAE,MAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAiBpG;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,GAAE,MAAkB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAU1H;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAMlG;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;IAC7B,2GAA2G;IAC3G,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAChC,UAAU,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAiBlD"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The machine's AI inventory, as `intutic connect` reports it every few
|
|
3
|
+
* minutes: every harness the detection rules find (connected or not), plus
|
|
4
|
+
* what the sync daemon reads about each (`collectDeviceInventory`), sent with
|
|
5
|
+
* the same device fingerprint `intutic enforce` reports under.
|
|
6
|
+
*
|
|
7
|
+
* Detection lives here because the rules are the CLI's harness adapters
|
|
8
|
+
* (`../harness/detector.ts`); the daemon package does not depend on the CLI.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { readdir } from 'node:fs/promises';
|
|
13
|
+
import { homedir, hostname } from 'node:os';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
import { collectDeviceInventory, reportDeviceInventory } from '@intutic/sync-daemon';
|
|
16
|
+
import { ALL_ADAPTERS } from '../harness/detector.js';
|
|
17
|
+
import { computeFingerprint, readEnforcementState } from './enforcementState.js';
|
|
18
|
+
/** At the default 30-second poll, every five minutes, starting with the first poll. */
|
|
19
|
+
export const INVENTORY_EVERY_N_POLLS = 10;
|
|
20
|
+
export function shouldReportInventoryThisIteration(pollIteration) {
|
|
21
|
+
return pollIteration % INVENTORY_EVERY_N_POLLS === 0;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* VS Code extensions whose installed directory name carries the version
|
|
25
|
+
* (`<publisher>.<name>-<version>`), the one version source cheap enough to
|
|
26
|
+
* read on every inventory cycle.
|
|
27
|
+
*/
|
|
28
|
+
const VSCODE_EXTENSION_PREFIX = {
|
|
29
|
+
'cline': 'saoudrizwan.claude-dev-',
|
|
30
|
+
'roo-code': 'rooveterinaryinc.roo-cline-',
|
|
31
|
+
'continue': 'continue.continue-',
|
|
32
|
+
};
|
|
33
|
+
/** The newest installed version of each extension-based harness, from directory names alone. */
|
|
34
|
+
export async function vscodeExtensionVersions(home = homedir()) {
|
|
35
|
+
let entries;
|
|
36
|
+
try {
|
|
37
|
+
entries = await readdir(join(home, '.vscode', 'extensions'));
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return new Map();
|
|
41
|
+
}
|
|
42
|
+
const out = new Map();
|
|
43
|
+
for (const [harness, prefix] of Object.entries(VSCODE_EXTENSION_PREFIX)) {
|
|
44
|
+
const versions = entries
|
|
45
|
+
.filter((e) => e.startsWith(prefix))
|
|
46
|
+
.map((e) => /^\d+\.\d+\.\d+/.exec(e.slice(prefix.length))?.[0])
|
|
47
|
+
.filter((v) => v !== undefined)
|
|
48
|
+
.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
|
|
49
|
+
if (versions[0])
|
|
50
|
+
out.set(harness, versions[0]);
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Every harness whose detection rule matches this machine and workspace. A
|
|
56
|
+
* rule that throws counts as not detected: one broken probe must not hide
|
|
57
|
+
* the rest.
|
|
58
|
+
*/
|
|
59
|
+
export async function detectInstalledHarnesses(workspaceRoot, home = homedir()) {
|
|
60
|
+
const versions = await vscodeExtensionVersions(home);
|
|
61
|
+
const found = [];
|
|
62
|
+
for (const adapter of ALL_ADAPTERS) {
|
|
63
|
+
const detected = await adapter.detect(workspaceRoot).catch(() => false);
|
|
64
|
+
if (!detected)
|
|
65
|
+
continue;
|
|
66
|
+
const version = versions.get(adapter.type);
|
|
67
|
+
found.push(version ? { type: adapter.type, version } : { type: adapter.type });
|
|
68
|
+
}
|
|
69
|
+
return found;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* This machine as `/api/v1/devices` knows it: the fingerprint in the local
|
|
73
|
+
* enforcement state when `intutic enforce` or `connect` has written one, so
|
|
74
|
+
* both views name the same device; otherwise the same fingerprint computed now.
|
|
75
|
+
*/
|
|
76
|
+
export async function inventoryDeviceIdentity(cliVersion) {
|
|
77
|
+
const state = await readEnforcementState();
|
|
78
|
+
if (state) {
|
|
79
|
+
return { fingerprint: state.fingerprint, hostname: state.hostname, platform: state.platform, cliVersion };
|
|
80
|
+
}
|
|
81
|
+
return { fingerprint: await computeFingerprint(), hostname: hostname(), platform: process.platform, cliVersion };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Detects, collects and sends the inventory. Never throws: the sync loop must
|
|
85
|
+
* not stop over a report the next cycle repeats anyway.
|
|
86
|
+
*/
|
|
87
|
+
export async function reportMachineInventory(opts) {
|
|
88
|
+
try {
|
|
89
|
+
const [detected, device] = await Promise.all([
|
|
90
|
+
detectInstalledHarnesses(opts.workspaceRoot),
|
|
91
|
+
inventoryDeviceIdentity(opts.cliVersion),
|
|
92
|
+
]);
|
|
93
|
+
const inventory = await collectDeviceInventory({
|
|
94
|
+
workspaceRoot: opts.workspaceRoot,
|
|
95
|
+
detected,
|
|
96
|
+
configured: opts.configured,
|
|
97
|
+
disconnected: opts.disconnected,
|
|
98
|
+
});
|
|
99
|
+
const reported = await reportDeviceInventory(opts.controlPlaneUrl, opts.apiKey, device, inventory);
|
|
100
|
+
return reported ? { reported } : { reported, reason: 'the control plane did not accept it' };
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
return { reported: false, reason: err instanceof Error ? err.message : String(err) };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory.js","sourceRoot":"","sources":["../../src/lib/inventory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GA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ACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAA;IACtF,CAAC;AACH,CAAC"}
|
package/dist/lib/logger.d.ts
CHANGED
package/dist/lib/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,GAAG;cACJ,MAAM,GAAG,IAAI;iBAIV,MAAM,GAAG,IAAI;cAIhB,MAAM,GAAG,IAAI;eAIZ,MAAM,GAAG,IAAI;aAIf,MAAM,GAAG,IAAI;IAItB,sCAAsC;iBACzB,MAAM,SAAS,MAAM,GAAG,IAAI;IAIzC,8BAA8B;gBAClB,MAAM,GAAG,IAAI;CAG1B,CAAA"}
|