@intutic/cli 1.10.0 → 2.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/README.md +1 -0
- package/dist/cli.js +868 -30
- package/dist/cli.js.map +1 -1
- package/dist/commands/attenuate.d.ts +39 -0
- package/dist/commands/attenuate.d.ts.map +1 -0
- package/dist/commands/attenuate.js +98 -0
- package/dist/commands/attenuate.js.map +1 -0
- package/dist/commands/budget.d.ts +80 -0
- package/dist/commands/budget.d.ts.map +1 -1
- package/dist/commands/budget.js +119 -3
- package/dist/commands/budget.js.map +1 -1
- package/dist/commands/connect.d.ts +10 -0
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +358 -48
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/credentials.d.ts +31 -0
- package/dist/commands/credentials.d.ts.map +1 -0
- package/dist/commands/credentials.js +134 -0
- package/dist/commands/credentials.js.map +1 -0
- package/dist/commands/decision.d.ts +37 -0
- package/dist/commands/decision.d.ts.map +1 -0
- package/dist/commands/decision.js +56 -0
- package/dist/commands/decision.js.map +1 -0
- package/dist/commands/doctor.d.ts +38 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +228 -18
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/enforce.d.ts +33 -0
- package/dist/commands/enforce.d.ts.map +1 -0
- package/dist/commands/enforce.js +150 -0
- package/dist/commands/enforce.js.map +1 -0
- package/dist/commands/enterprise.d.ts +29 -0
- package/dist/commands/enterprise.d.ts.map +1 -0
- package/dist/commands/enterprise.js +141 -0
- package/dist/commands/enterprise.js.map +1 -0
- package/dist/commands/env.d.ts +7 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/env.js +55 -0
- package/dist/commands/env.js.map +1 -0
- package/dist/commands/exec.d.ts +38 -2
- package/dist/commands/exec.d.ts.map +1 -1
- package/dist/commands/exec.js +247 -10
- package/dist/commands/exec.js.map +1 -1
- package/dist/commands/findings.d.ts +84 -0
- package/dist/commands/findings.d.ts.map +1 -0
- package/dist/commands/findings.js +329 -0
- package/dist/commands/findings.js.map +1 -0
- package/dist/commands/gateway.d.ts +62 -0
- package/dist/commands/gateway.d.ts.map +1 -0
- package/dist/commands/gateway.js +298 -0
- package/dist/commands/gateway.js.map +1 -0
- package/dist/commands/guardrails.d.ts +81 -0
- package/dist/commands/guardrails.d.ts.map +1 -0
- package/dist/commands/guardrails.js +735 -0
- package/dist/commands/guardrails.js.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +14 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install-daemon.d.ts +70 -3
- package/dist/commands/install-daemon.d.ts.map +1 -1
- package/dist/commands/install-daemon.js +482 -47
- package/dist/commands/install-daemon.js.map +1 -1
- package/dist/commands/integrity.d.ts +205 -0
- package/dist/commands/integrity.d.ts.map +1 -0
- package/dist/commands/integrity.js +620 -0
- package/dist/commands/integrity.js.map +1 -0
- package/dist/commands/judge.d.ts +31 -0
- package/dist/commands/judge.d.ts.map +1 -0
- package/dist/commands/judge.js +118 -0
- package/dist/commands/judge.js.map +1 -0
- package/dist/commands/org.d.ts +31 -0
- package/dist/commands/org.d.ts.map +1 -0
- package/dist/commands/org.js +159 -0
- package/dist/commands/org.js.map +1 -0
- package/dist/commands/policy.d.ts +138 -4
- package/dist/commands/policy.d.ts.map +1 -1
- package/dist/commands/policy.js +538 -97
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/predict-cost.d.ts +45 -0
- package/dist/commands/predict-cost.d.ts.map +1 -0
- package/dist/commands/predict-cost.js +123 -0
- package/dist/commands/predict-cost.js.map +1 -0
- package/dist/commands/rollback.d.ts +5 -0
- package/dist/commands/rollback.d.ts.map +1 -0
- package/dist/commands/rollback.js +142 -0
- package/dist/commands/rollback.js.map +1 -0
- package/dist/commands/routing.d.ts +62 -0
- package/dist/commands/routing.d.ts.map +1 -0
- package/dist/commands/routing.js +121 -0
- package/dist/commands/routing.js.map +1 -0
- package/dist/commands/setup.d.ts +62 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +238 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/skill.d.ts +268 -1
- package/dist/commands/skill.d.ts.map +1 -1
- package/dist/commands/skill.js +744 -39
- package/dist/commands/skill.js.map +1 -1
- package/dist/commands/sops.d.ts +95 -0
- package/dist/commands/sops.d.ts.map +1 -1
- package/dist/commands/sops.js +334 -34
- package/dist/commands/sops.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +1 -18
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +44 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/team.d.ts +38 -0
- package/dist/commands/team.d.ts.map +1 -0
- package/dist/commands/team.js +140 -0
- package/dist/commands/team.js.map +1 -0
- package/dist/commands/traces.d.ts +8 -1
- package/dist/commands/traces.d.ts.map +1 -1
- package/dist/commands/traces.js +114 -15
- package/dist/commands/traces.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +2 -1
- package/dist/commands/whoami.js.map +1 -1
- package/dist/config/keychain.d.ts +10 -2
- package/dist/config/keychain.d.ts.map +1 -1
- package/dist/config/keychain.js +83 -14
- package/dist/config/keychain.js.map +1 -1
- package/dist/config/paths.d.ts +27 -0
- package/dist/config/paths.d.ts.map +1 -1
- package/dist/config/paths.js +37 -6
- package/dist/config/paths.js.map +1 -1
- package/dist/config/store.d.ts.map +1 -1
- package/dist/config/store.js +19 -3
- package/dist/config/store.js.map +1 -1
- package/dist/harness/ag2.d.ts +22 -0
- package/dist/harness/ag2.d.ts.map +1 -0
- package/dist/harness/ag2.js +34 -0
- package/dist/harness/ag2.js.map +1 -0
- package/dist/harness/agentcore.d.ts +55 -0
- package/dist/harness/agentcore.d.ts.map +1 -0
- package/dist/harness/agentcore.js +119 -0
- package/dist/harness/agentcore.js.map +1 -0
- package/dist/harness/agenticOrchestrator.d.ts +52 -0
- package/dist/harness/agenticOrchestrator.d.ts.map +1 -0
- package/dist/harness/agenticOrchestrator.js +115 -0
- package/dist/harness/agenticOrchestrator.js.map +1 -0
- package/dist/harness/aiSdkHarness.d.ts +30 -0
- package/dist/harness/aiSdkHarness.d.ts.map +1 -0
- package/dist/harness/aiSdkHarness.js +51 -0
- package/dist/harness/aiSdkHarness.js.map +1 -0
- package/dist/harness/aiSdkWorkflow.d.ts +26 -0
- package/dist/harness/aiSdkWorkflow.d.ts.map +1 -0
- package/dist/harness/aiSdkWorkflow.js +39 -0
- package/dist/harness/aiSdkWorkflow.js.map +1 -0
- package/dist/harness/autogen.d.ts +24 -0
- package/dist/harness/autogen.d.ts.map +1 -0
- package/dist/harness/autogen.js +36 -0
- package/dist/harness/autogen.js.map +1 -0
- package/dist/harness/base.js.map +1 -1
- package/dist/harness/continue.d.ts.map +1 -1
- package/dist/harness/continue.js +2 -1
- package/dist/harness/continue.js.map +1 -1
- package/dist/harness/crewai.d.ts +15 -0
- package/dist/harness/crewai.d.ts.map +1 -0
- package/dist/harness/crewai.js +26 -0
- package/dist/harness/crewai.js.map +1 -0
- package/dist/harness/detector.d.ts +1 -1
- package/dist/harness/detector.d.ts.map +1 -1
- package/dist/harness/detector.js +47 -1
- package/dist/harness/detector.js.map +1 -1
- package/dist/harness/dsh.d.ts +19 -0
- package/dist/harness/dsh.d.ts.map +1 -0
- package/dist/harness/dsh.js +93 -0
- package/dist/harness/dsh.js.map +1 -0
- package/dist/harness/eve.d.ts +40 -0
- package/dist/harness/eve.d.ts.map +1 -0
- package/dist/harness/eve.js +67 -0
- package/dist/harness/eve.js.map +1 -0
- package/dist/harness/googleAdk.d.ts +18 -0
- package/dist/harness/googleAdk.d.ts.map +1 -0
- package/dist/harness/googleAdk.js +29 -0
- package/dist/harness/googleAdk.js.map +1 -0
- package/dist/harness/goose.d.ts.map +1 -1
- package/dist/harness/goose.js +5 -1
- package/dist/harness/goose.js.map +1 -1
- package/dist/harness/grok.d.ts +16 -0
- package/dist/harness/grok.d.ts.map +1 -0
- package/dist/harness/grok.js +78 -0
- package/dist/harness/grok.js.map +1 -0
- package/dist/harness/jsSdkGatedAdapter.d.ts +102 -0
- package/dist/harness/jsSdkGatedAdapter.d.ts.map +1 -0
- package/dist/harness/jsSdkGatedAdapter.js +139 -0
- package/dist/harness/jsSdkGatedAdapter.js.map +1 -0
- package/dist/harness/langchain.d.ts +22 -0
- package/dist/harness/langchain.d.ts.map +1 -0
- package/dist/harness/langchain.js +33 -0
- package/dist/harness/langchain.js.map +1 -0
- package/dist/harness/langgraph.d.ts +22 -0
- package/dist/harness/langgraph.d.ts.map +1 -0
- package/dist/harness/langgraph.js +80 -0
- package/dist/harness/langgraph.js.map +1 -0
- package/dist/harness/mastra.d.ts +21 -0
- package/dist/harness/mastra.d.ts.map +1 -0
- package/dist/harness/mastra.js +33 -0
- package/dist/harness/mastra.js.map +1 -0
- package/dist/harness/muse.d.ts +22 -0
- package/dist/harness/muse.d.ts.map +1 -0
- package/dist/harness/muse.js +92 -0
- package/dist/harness/muse.js.map +1 -0
- package/dist/harness/n8n.d.ts.map +1 -1
- package/dist/harness/n8n.js +36 -11
- package/dist/harness/n8n.js.map +1 -1
- package/dist/harness/openaiAgents.d.ts +40 -0
- package/dist/harness/openaiAgents.d.ts.map +1 -0
- package/dist/harness/openaiAgents.js +107 -0
- package/dist/harness/openaiAgents.js.map +1 -0
- package/dist/harness/opencode.d.ts +24 -0
- package/dist/harness/opencode.d.ts.map +1 -0
- package/dist/harness/opencode.js +97 -0
- package/dist/harness/opencode.js.map +1 -0
- package/dist/harness/pydanticAi.d.ts +19 -0
- package/dist/harness/pydanticAi.d.ts.map +1 -0
- package/dist/harness/pydanticAi.js +30 -0
- package/dist/harness/pydanticAi.js.map +1 -0
- package/dist/harness/sdkGatedAdapter.d.ts +55 -0
- package/dist/harness/sdkGatedAdapter.d.ts.map +1 -0
- package/dist/harness/sdkGatedAdapter.js +85 -0
- package/dist/harness/sdkGatedAdapter.js.map +1 -0
- package/dist/harness/smolagents.d.ts +22 -0
- package/dist/harness/smolagents.d.ts.map +1 -0
- package/dist/harness/smolagents.js +33 -0
- package/dist/harness/smolagents.js.map +1 -0
- package/dist/harness/strands.d.ts +22 -0
- package/dist/harness/strands.d.ts.map +1 -0
- package/dist/harness/strands.js +35 -0
- package/dist/harness/strands.js.map +1 -0
- package/dist/harness/trueforge.d.ts +25 -0
- package/dist/harness/trueforge.d.ts.map +1 -0
- package/dist/harness/trueforge.js +40 -0
- package/dist/harness/trueforge.js.map +1 -0
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js +70 -0
- package/dist/harness/types.js.map +1 -1
- package/dist/harness/vercelAiSdk.d.ts +31 -0
- package/dist/harness/vercelAiSdk.d.ts.map +1 -0
- package/dist/harness/vercelAiSdk.js +44 -0
- package/dist/harness/vercelAiSdk.js.map +1 -0
- package/dist/harness/xirp.d.ts +43 -0
- package/dist/harness/xirp.d.ts.map +1 -0
- package/dist/harness/xirp.js +95 -0
- package/dist/harness/xirp.js.map +1 -0
- package/dist/lib/api.d.ts +68 -0
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +108 -67
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/authMessages.d.ts +19 -0
- package/dist/lib/authMessages.d.ts.map +1 -0
- package/dist/lib/authMessages.js +20 -0
- package/dist/lib/authMessages.js.map +1 -0
- package/dist/lib/binaryChecksum.d.ts +12 -0
- package/dist/lib/binaryChecksum.d.ts.map +1 -0
- package/dist/lib/binaryChecksum.js +45 -0
- package/dist/lib/binaryChecksum.js.map +1 -0
- package/dist/lib/binaryOnPath.d.ts +24 -0
- package/dist/lib/binaryOnPath.d.ts.map +1 -0
- package/dist/lib/binaryOnPath.js +31 -0
- package/dist/lib/binaryOnPath.js.map +1 -0
- package/dist/lib/caTrust.d.ts +69 -0
- package/dist/lib/caTrust.d.ts.map +1 -0
- package/dist/lib/caTrust.js +169 -0
- package/dist/lib/caTrust.js.map +1 -0
- package/dist/lib/ciscoScanner.d.ts +178 -0
- package/dist/lib/ciscoScanner.d.ts.map +1 -0
- package/dist/lib/ciscoScanner.js +292 -0
- package/dist/lib/ciscoScanner.js.map +1 -0
- package/dist/lib/decisionsLogRefresh.d.ts +28 -0
- package/dist/lib/decisionsLogRefresh.d.ts.map +1 -0
- package/dist/lib/decisionsLogRefresh.js +54 -0
- package/dist/lib/decisionsLogRefresh.js.map +1 -0
- package/dist/lib/deviceReport.d.ts +26 -0
- package/dist/lib/deviceReport.d.ts.map +1 -0
- package/dist/lib/deviceReport.js +55 -0
- package/dist/lib/deviceReport.js.map +1 -0
- package/dist/lib/elevation.d.ts +58 -0
- package/dist/lib/elevation.d.ts.map +1 -0
- package/dist/lib/elevation.js +83 -0
- package/dist/lib/elevation.js.map +1 -0
- package/dist/lib/enforcementState.d.ts +69 -0
- package/dist/lib/enforcementState.d.ts.map +1 -0
- package/dist/lib/enforcementState.js +113 -0
- package/dist/lib/enforcementState.js.map +1 -0
- package/dist/lib/ensureValkey.d.ts.map +1 -1
- package/dist/lib/ensureValkey.js +2 -2
- package/dist/lib/ensureValkey.js.map +1 -1
- package/dist/lib/envInjector.d.ts.map +1 -1
- package/dist/lib/envInjector.js +22 -4
- package/dist/lib/envInjector.js.map +1 -1
- package/dist/lib/gitHooks.d.ts +7 -2
- package/dist/lib/gitHooks.d.ts.map +1 -1
- package/dist/lib/gitHooks.js +180 -13
- package/dist/lib/gitHooks.js.map +1 -1
- package/dist/lib/gracefulShutdown.d.ts +37 -0
- package/dist/lib/gracefulShutdown.d.ts.map +1 -0
- package/dist/lib/gracefulShutdown.js +57 -0
- package/dist/lib/gracefulShutdown.js.map +1 -0
- package/dist/lib/graphIdentity.d.ts +80 -0
- package/dist/lib/graphIdentity.d.ts.map +1 -0
- package/dist/lib/graphIdentity.js +120 -0
- package/dist/lib/graphIdentity.js.map +1 -0
- package/dist/lib/localTraces.d.ts +61 -0
- package/dist/lib/localTraces.d.ts.map +1 -0
- package/dist/lib/localTraces.js +173 -0
- package/dist/lib/localTraces.js.map +1 -0
- package/dist/lib/mdmManifest.d.ts +73 -0
- package/dist/lib/mdmManifest.d.ts.map +1 -0
- package/dist/lib/mdmManifest.js +190 -0
- package/dist/lib/mdmManifest.js.map +1 -0
- package/dist/lib/onboarding.d.ts.map +1 -1
- package/dist/lib/onboarding.js +60 -1
- package/dist/lib/onboarding.js.map +1 -1
- package/dist/lib/otelPropagation.d.ts +26 -0
- package/dist/lib/otelPropagation.d.ts.map +1 -0
- package/dist/lib/otelPropagation.js +40 -0
- package/dist/lib/otelPropagation.js.map +1 -0
- package/dist/lib/policySnapshot.d.ts +92 -0
- package/dist/lib/policySnapshot.d.ts.map +1 -0
- package/dist/lib/policySnapshot.js +173 -0
- package/dist/lib/policySnapshot.js.map +1 -0
- package/dist/lib/process.d.ts.map +1 -1
- package/dist/lib/process.js +60 -0
- package/dist/lib/process.js.map +1 -1
- package/dist/lib/providerProbe.d.ts +28 -0
- package/dist/lib/providerProbe.d.ts.map +1 -0
- package/dist/lib/providerProbe.js +57 -0
- package/dist/lib/providerProbe.js.map +1 -0
- package/dist/lib/proxyBinary.d.ts +19 -0
- package/dist/lib/proxyBinary.d.ts.map +1 -0
- package/dist/lib/proxyBinary.js +30 -0
- package/dist/lib/proxyBinary.js.map +1 -0
- package/dist/lib/sandbox/firecracker.d.ts +89 -0
- package/dist/lib/sandbox/firecracker.d.ts.map +1 -0
- package/dist/lib/sandbox/firecracker.js +135 -0
- package/dist/lib/sandbox/firecracker.js.map +1 -0
- package/dist/lib/sandbox/index.d.ts +34 -0
- package/dist/lib/sandbox/index.d.ts.map +1 -0
- package/dist/lib/sandbox/index.js +54 -0
- package/dist/lib/sandbox/index.js.map +1 -0
- package/dist/lib/sandbox/oci.d.ts +38 -0
- package/dist/lib/sandbox/oci.d.ts.map +1 -0
- package/dist/lib/sandbox/oci.js +108 -0
- package/dist/lib/sandbox/oci.js.map +1 -0
- package/dist/lib/sandbox/types.d.ts +48 -0
- package/dist/lib/sandbox/types.d.ts.map +1 -0
- package/dist/lib/sandbox/types.js +12 -0
- package/dist/lib/sandbox/types.js.map +1 -0
- package/dist/lib/sopFrontMatter.d.ts +50 -0
- package/dist/lib/sopFrontMatter.d.ts.map +1 -0
- package/dist/lib/sopFrontMatter.js +129 -0
- package/dist/lib/sopFrontMatter.js.map +1 -0
- package/package.json +11 -6
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* decisionsLogRefresh.ts — best-effort, one-shot refresh of the governed
|
|
3
|
+
* decisions log, triggered by the optional post-merge git hook
|
|
4
|
+
* (`gitHooks.ts`'s `POST_MERGE_CONTENT`) so a developer sees fresh decisions
|
|
5
|
+
* right after a merge rather than waiting for the daemon's next ~30s poll.
|
|
6
|
+
* Never throws — a backgrounded hook must not surface a failure to the shell,
|
|
7
|
+
* same posture as `deviceReport.ts`'s "best-effort phone-home".
|
|
8
|
+
*
|
|
9
|
+
* Reuses `@intutic/sync-daemon`'s `refreshDecisionsDigest` directly rather
|
|
10
|
+
* than re-implementing the fetch/render/write.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
export interface DecisionsLogRefreshResult {
|
|
15
|
+
refreshed: boolean;
|
|
16
|
+
reason?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Checks `WorkspaceSettings.decisionsLogEnabled` before writing anything.
|
|
20
|
+
*
|
|
21
|
+
* This is a manually-triggered, one-shot refresh, not the daemon's own gated
|
|
22
|
+
* poll-cycle call — it has to re-check the opt-in itself rather than
|
|
23
|
+
* inheriting the daemon's own gate, or a developer merging a branch would
|
|
24
|
+
* cause files to be written into a workspace that never turned this feature
|
|
25
|
+
* on.
|
|
26
|
+
*/
|
|
27
|
+
export declare function refreshDecisionsLog(workspaceRoot: string): Promise<DecisionsLogRefreshResult>;
|
|
28
|
+
//# sourceMappingURL=decisionsLogRefresh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decisionsLogRefresh.d.ts","sourceRoot":"","sources":["../../src/lib/decisionsLogRefresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,CA4BnG"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* decisionsLogRefresh.ts — best-effort, one-shot refresh of the governed
|
|
3
|
+
* decisions log, triggered by the optional post-merge git hook
|
|
4
|
+
* (`gitHooks.ts`'s `POST_MERGE_CONTENT`) so a developer sees fresh decisions
|
|
5
|
+
* right after a merge rather than waiting for the daemon's next ~30s poll.
|
|
6
|
+
* Never throws — a backgrounded hook must not surface a failure to the shell,
|
|
7
|
+
* same posture as `deviceReport.ts`'s "best-effort phone-home".
|
|
8
|
+
*
|
|
9
|
+
* Reuses `@intutic/sync-daemon`'s `refreshDecisionsDigest` directly rather
|
|
10
|
+
* than re-implementing the fetch/render/write.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import { loadCredentials } from '../config/store.js';
|
|
15
|
+
import { createApiClient } from './api.js';
|
|
16
|
+
import { refreshDecisionsDigest } from '@intutic/sync-daemon';
|
|
17
|
+
import { HarnessType } from '@intutic/shared-types';
|
|
18
|
+
/**
|
|
19
|
+
* Checks `WorkspaceSettings.decisionsLogEnabled` before writing anything.
|
|
20
|
+
*
|
|
21
|
+
* This is a manually-triggered, one-shot refresh, not the daemon's own gated
|
|
22
|
+
* poll-cycle call — it has to re-check the opt-in itself rather than
|
|
23
|
+
* inheriting the daemon's own gate, or a developer merging a branch would
|
|
24
|
+
* cause files to be written into a workspace that never turned this feature
|
|
25
|
+
* on.
|
|
26
|
+
*/
|
|
27
|
+
export async function refreshDecisionsLog(workspaceRoot) {
|
|
28
|
+
try {
|
|
29
|
+
const creds = await loadCredentials();
|
|
30
|
+
if (!creds)
|
|
31
|
+
return { refreshed: false, reason: 'not authenticated' };
|
|
32
|
+
const client = createApiClient(creds.controlPlaneUrl, creds.apiKey);
|
|
33
|
+
const { settings } = await client.get('/api/v1/workspace/settings');
|
|
34
|
+
if (!settings?.decisionsLogEnabled) {
|
|
35
|
+
return { refreshed: false, reason: 'decisionsLogEnabled is off' };
|
|
36
|
+
}
|
|
37
|
+
// The claude-code harness is the sole injection target (see
|
|
38
|
+
// decisionsDigest.ts's own doc comment) — passed unconditionally here
|
|
39
|
+
// since this one-shot trigger has no live harness-detection cycle to
|
|
40
|
+
// draw from the way the daemon's sync loop does.
|
|
41
|
+
const result = await refreshDecisionsDigest({
|
|
42
|
+
controlPlaneUrl: creds.controlPlaneUrl,
|
|
43
|
+
apiKey: creds.apiKey,
|
|
44
|
+
workspaceId: creds.workspaceId,
|
|
45
|
+
workspaceRoot,
|
|
46
|
+
harnesses: [HarnessType.CLAUDE_CODE],
|
|
47
|
+
});
|
|
48
|
+
return result ? { refreshed: true } : { refreshed: false, reason: 'digest fetch failed' };
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
return { refreshed: false, reason: err instanceof Error ? err.message : String(err) };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=decisionsLogRefresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decisionsLogRefresh.js","sourceRoot":"","sources":["../../src/lib/decisionsLogRefresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,C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,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAA;IACvF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort phone-home: reads local enforcement state (A4) and reports it
|
|
3
|
+
* to the control plane's `/api/v1/devices/report` (A6) — the "continuous"
|
|
4
|
+
* half of "continuous compliance and enforcement". Never throws: the
|
|
5
|
+
* underlying privileged action (`enforce apply/remove`, `enterprise
|
|
6
|
+
* install`) already succeeded or failed on its own merits before this runs;
|
|
7
|
+
* a report failure must not turn that into a command failure.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
export interface DeviceReportResult {
|
|
12
|
+
reported: boolean;
|
|
13
|
+
reason?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ReportDeviceStateOptions {
|
|
16
|
+
dev?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reads `~/.intutic/` credentials and the local enforcement state file, and
|
|
20
|
+
* POSTs whatever legs are present. A `sudo`-elevated caller with no
|
|
21
|
+
* readable credentials (root can't read a Keychain-backed API key) simply
|
|
22
|
+
* reports `reported: false` — the caller decides whether that's worth
|
|
23
|
+
* surfacing, this function never throws over it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function reportDeviceState(opts?: ReportDeviceStateOptions): Promise<DeviceReportResult>;
|
|
26
|
+
//# sourceMappingURL=deviceReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceReport.d.ts","sourceRoot":"","sources":["../../src/lib/deviceReport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,GAAE,wBAA6B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA8BxG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort phone-home: reads local enforcement state (A4) and reports it
|
|
3
|
+
* to the control plane's `/api/v1/devices/report` (A6) — the "continuous"
|
|
4
|
+
* half of "continuous compliance and enforcement". Never throws: the
|
|
5
|
+
* underlying privileged action (`enforce apply/remove`, `enterprise
|
|
6
|
+
* install`) already succeeded or failed on its own merits before this runs;
|
|
7
|
+
* a report failure must not turn that into a command failure.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
12
|
+
import { loadCredentials } from '../config/store.js';
|
|
13
|
+
import { resolveControlPlaneUrl } from '../config/paths.js';
|
|
14
|
+
import { createApiClient } from './api.js';
|
|
15
|
+
import { readEnforcementState } from './enforcementState.js';
|
|
16
|
+
const { version: cliVersion } = createRequire(import.meta.url)('../../package.json');
|
|
17
|
+
/**
|
|
18
|
+
* Reads `~/.intutic/` credentials and the local enforcement state file, and
|
|
19
|
+
* POSTs whatever legs are present. A `sudo`-elevated caller with no
|
|
20
|
+
* readable credentials (root can't read a Keychain-backed API key) simply
|
|
21
|
+
* reports `reported: false` — the caller decides whether that's worth
|
|
22
|
+
* surfacing, this function never throws over it.
|
|
23
|
+
*/
|
|
24
|
+
export async function reportDeviceState(opts = {}) {
|
|
25
|
+
try {
|
|
26
|
+
const creds = await loadCredentials();
|
|
27
|
+
if (!creds)
|
|
28
|
+
return { reported: false, reason: 'not authenticated' };
|
|
29
|
+
const state = await readEnforcementState();
|
|
30
|
+
if (!state)
|
|
31
|
+
return { reported: false, reason: 'no local enforcement state recorded yet' };
|
|
32
|
+
const body = {
|
|
33
|
+
fingerprint: state.fingerprint,
|
|
34
|
+
hostname: state.hostname,
|
|
35
|
+
platform: state.platform,
|
|
36
|
+
cliVersion: state.cliVersion ?? cliVersion,
|
|
37
|
+
};
|
|
38
|
+
if (state.firewall) {
|
|
39
|
+
body.firewall = { active: state.firewall.active, backend: state.firewall.backend, detail: state.firewall.detail };
|
|
40
|
+
}
|
|
41
|
+
if (state.caTrust) {
|
|
42
|
+
body.caTrust = { installed: state.caTrust.installed, scope: state.caTrust.scope };
|
|
43
|
+
}
|
|
44
|
+
if (state.systemHooks) {
|
|
45
|
+
body.systemHooks = { installed: state.systemHooks.installed, path: state.systemHooks.path };
|
|
46
|
+
}
|
|
47
|
+
const client = createApiClient(resolveControlPlaneUrl(opts.dev), creds.apiKey);
|
|
48
|
+
await client.post('/api/v1/devices/report', body);
|
|
49
|
+
return { reported: true };
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
return { reported: false, reason: err instanceof Error ? err.message : String(err) };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=deviceReport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceReport.js","sourceRoot":"","sources":["../../src/lib/deviceReport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAE5D,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAwB,CAAA;AAW3G;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAiC,EAAE;IACzE,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,e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AC,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAA;QACjD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;IAC3B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,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"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Privilege + invoking-user-home resolution, shared by `enterprise install`
|
|
3
|
+
* (`commands/enterprise.ts`) and `enforce`'s reporting leg (`commands/enforce.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Two bugs in the deleted `enterprise-install.ts` motivate this module rather
|
|
6
|
+
* than a copy of what it did:
|
|
7
|
+
*
|
|
8
|
+
* 1. Its Windows elevation check was `process.env.USERNAME === 'Administrator'
|
|
9
|
+
* || process.env.IS_ADMIN === '1'` — wrong on essentially every real
|
|
10
|
+
* machine (the built-in Administrator account is disabled by default, and
|
|
11
|
+
* `IS_ADMIN` is not a variable Windows or any installer sets). It would
|
|
12
|
+
* have reported "not elevated" for every real admin session.
|
|
13
|
+
* 2. It read `~/.intutic/ca.crt` via `os.homedir()`. Under `sudo`,
|
|
14
|
+
* `os.homedir()` resolves to `/var/root` (macOS) or `/root` (Linux) — the
|
|
15
|
+
* invoking user's home, not root's — so that read always threw ENOENT and
|
|
16
|
+
* the command silently skipped CA installation. Confirmed: zero
|
|
17
|
+
* `SUDO_USER`/`SUDO_UID` references exist anywhere else in this tree.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* `'unknown'` on platforms/paths where no reliable synchronous check exists
|
|
23
|
+
* (Windows) — callers should attempt-and-report on `'unknown'`, matching
|
|
24
|
+
* `enforce.ts`'s existing "warn, but still try; the OS gives the precise
|
|
25
|
+
* error if privilege really is missing" discipline, rather than pre-blocking
|
|
26
|
+
* on a guess.
|
|
27
|
+
*/
|
|
28
|
+
export type Elevation = 'elevated' | 'unelevated' | 'unknown';
|
|
29
|
+
/** Synchronous, POSIX-only (real euid check). Always `'unknown'` on Windows. */
|
|
30
|
+
export declare function isElevatedSync(): Elevation;
|
|
31
|
+
/**
|
|
32
|
+
* Resolves `'unknown'` into a real answer on Windows by probing `net
|
|
33
|
+
* session`, which only an elevated process can run (it fails with "Access is
|
|
34
|
+
* denied" otherwise). No dependency on environment variables an installer or
|
|
35
|
+
* shell may or may not set.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isElevatedAsync(): Promise<Elevation>;
|
|
38
|
+
/**
|
|
39
|
+
* The real invoking user's home directory, even when running as root under
|
|
40
|
+
* `sudo`. `os.homedir()` under `sudo` resolves to root's home
|
|
41
|
+
* (`/var/root`/`/root`), not the real user's — the deleted `enterprise-install.ts`
|
|
42
|
+
* never handled this and its CA-cert read (`~/.intutic/ca.crt`) always threw
|
|
43
|
+
* ENOENT when actually run elevated.
|
|
44
|
+
*
|
|
45
|
+
* Node's `os.userInfo()` cannot look up an arbitrary user by uid — despite
|
|
46
|
+
* accepting a `uid` option at the type level in some environments, it always
|
|
47
|
+
* returns the CALLING process's own identity regardless of what's passed
|
|
48
|
+
* (verified: `userInfo({ uid: 0 })` as a non-root user still returns that
|
|
49
|
+
* user's own info, not root's). So the only real option without shelling out
|
|
50
|
+
* to `dscl`/`getent` is the path convention every real deployment follows:
|
|
51
|
+
* `/Users/$SUDO_USER` on macOS, `/home/$SUDO_USER` on Linux. This is a
|
|
52
|
+
* correctness improvement over the status quo (silently resolving to root's
|
|
53
|
+
* home) even though it is a convention, not a guaranteed-correct lookup.
|
|
54
|
+
*/
|
|
55
|
+
export declare function invokingUserHome(): string;
|
|
56
|
+
/** The invoking user's `~/.intutic` (or platform equivalent), sudo-aware. */
|
|
57
|
+
export declare function invokingUserIntuticDir(): string;
|
|
58
|
+
//# sourceMappingURL=elevation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elevation.d.ts","sourceRoot":"","sources":["../../src/lib/elevation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,CAAA;AAE7D,gFAAgF;AAChF,wBAAgB,cAAc,IAAI,SAAS,CAK1C;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAa1D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAQzC;AAED,6EAA6E;AAC7E,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Privilege + invoking-user-home resolution, shared by `enterprise install`
|
|
3
|
+
* (`commands/enterprise.ts`) and `enforce`'s reporting leg (`commands/enforce.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Two bugs in the deleted `enterprise-install.ts` motivate this module rather
|
|
6
|
+
* than a copy of what it did:
|
|
7
|
+
*
|
|
8
|
+
* 1. Its Windows elevation check was `process.env.USERNAME === 'Administrator'
|
|
9
|
+
* || process.env.IS_ADMIN === '1'` — wrong on essentially every real
|
|
10
|
+
* machine (the built-in Administrator account is disabled by default, and
|
|
11
|
+
* `IS_ADMIN` is not a variable Windows or any installer sets). It would
|
|
12
|
+
* have reported "not elevated" for every real admin session.
|
|
13
|
+
* 2. It read `~/.intutic/ca.crt` via `os.homedir()`. Under `sudo`,
|
|
14
|
+
* `os.homedir()` resolves to `/var/root` (macOS) or `/root` (Linux) — the
|
|
15
|
+
* invoking user's home, not root's — so that read always threw ENOENT and
|
|
16
|
+
* the command silently skipped CA installation. Confirmed: zero
|
|
17
|
+
* `SUDO_USER`/`SUDO_UID` references exist anywhere else in this tree.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import { execFile } from 'node:child_process';
|
|
22
|
+
import { promisify } from 'node:util';
|
|
23
|
+
import { homedir } from 'node:os';
|
|
24
|
+
import { getIntuticDirFor } from '../config/paths.js';
|
|
25
|
+
const execFileAsync = promisify(execFile);
|
|
26
|
+
/** Synchronous, POSIX-only (real euid check). Always `'unknown'` on Windows. */
|
|
27
|
+
export function isElevatedSync() {
|
|
28
|
+
if (typeof process.getuid === 'function') {
|
|
29
|
+
return process.getuid() === 0 ? 'elevated' : 'unelevated';
|
|
30
|
+
}
|
|
31
|
+
return 'unknown';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolves `'unknown'` into a real answer on Windows by probing `net
|
|
35
|
+
* session`, which only an elevated process can run (it fails with "Access is
|
|
36
|
+
* denied" otherwise). No dependency on environment variables an installer or
|
|
37
|
+
* shell may or may not set.
|
|
38
|
+
*/
|
|
39
|
+
export async function isElevatedAsync() {
|
|
40
|
+
const sync = isElevatedSync();
|
|
41
|
+
if (sync !== 'unknown')
|
|
42
|
+
return sync;
|
|
43
|
+
if (process.platform === 'win32') {
|
|
44
|
+
try {
|
|
45
|
+
await execFileAsync('net', ['session'], { timeout: 3000 });
|
|
46
|
+
return 'elevated';
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return 'unelevated';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return 'unknown';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The real invoking user's home directory, even when running as root under
|
|
56
|
+
* `sudo`. `os.homedir()` under `sudo` resolves to root's home
|
|
57
|
+
* (`/var/root`/`/root`), not the real user's — the deleted `enterprise-install.ts`
|
|
58
|
+
* never handled this and its CA-cert read (`~/.intutic/ca.crt`) always threw
|
|
59
|
+
* ENOENT when actually run elevated.
|
|
60
|
+
*
|
|
61
|
+
* Node's `os.userInfo()` cannot look up an arbitrary user by uid — despite
|
|
62
|
+
* accepting a `uid` option at the type level in some environments, it always
|
|
63
|
+
* returns the CALLING process's own identity regardless of what's passed
|
|
64
|
+
* (verified: `userInfo({ uid: 0 })` as a non-root user still returns that
|
|
65
|
+
* user's own info, not root's). So the only real option without shelling out
|
|
66
|
+
* to `dscl`/`getent` is the path convention every real deployment follows:
|
|
67
|
+
* `/Users/$SUDO_USER` on macOS, `/home/$SUDO_USER` on Linux. This is a
|
|
68
|
+
* correctness improvement over the status quo (silently resolving to root's
|
|
69
|
+
* home) even though it is a convention, not a guaranteed-correct lookup.
|
|
70
|
+
*/
|
|
71
|
+
export function invokingUserHome() {
|
|
72
|
+
const isRoot = typeof process.getuid === 'function' && process.getuid() === 0;
|
|
73
|
+
const sudoUser = process.env.SUDO_USER;
|
|
74
|
+
if (!isRoot || !sudoUser) {
|
|
75
|
+
return homedir();
|
|
76
|
+
}
|
|
77
|
+
return process.platform === 'darwin' ? `/Users/${sudoUser}` : `/home/${sudoUser}`;
|
|
78
|
+
}
|
|
79
|
+
/** The invoking user's `~/.intutic` (or platform equivalent), sudo-aware. */
|
|
80
|
+
export function invokingUserIntuticDir() {
|
|
81
|
+
return getIntuticDirFor(invokingUserHome());
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=elevation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elevation.js","sourceRoot":"","sources":["../../src/lib/elevation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;AAWzC,gFAAgF;AAChF,MAAM,UA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AA;AAC7C,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local, unprivileged-readable record of a machine's enforcement posture —
|
|
3
|
+
* firewall, CA trust, system hooks. Solves two problems together:
|
|
4
|
+
*
|
|
5
|
+
* 1. `intutic enforce status` needs root to query the underlying firewall
|
|
6
|
+
* tool (e.g. `pfctl`) on macOS, so an unprivileged run can't truthfully
|
|
7
|
+
* answer "is enforcement actually on?".
|
|
8
|
+
* 2. A `sudo`-elevated process can't read the real user's stored API
|
|
9
|
+
* credentials (Keychain-backed on macOS), so it can't itself report
|
|
10
|
+
* posture to the control plane.
|
|
11
|
+
*
|
|
12
|
+
* So: the privileged action (`enforce apply/remove`, `enterprise install`)
|
|
13
|
+
* records the truth here, locally, as it happens; a separate, unprivileged
|
|
14
|
+
* step (`enforce report`, `connect.ts`'s periodic loop — see A7) reads this
|
|
15
|
+
* file and ships it.
|
|
16
|
+
*
|
|
17
|
+
* World-readable, no secrets in it — device posture only.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
export interface FirewallLeg {
|
|
22
|
+
active: boolean;
|
|
23
|
+
backend?: string;
|
|
24
|
+
detail?: string;
|
|
25
|
+
reportedAt: string;
|
|
26
|
+
}
|
|
27
|
+
export interface CaTrustLeg {
|
|
28
|
+
installed: boolean;
|
|
29
|
+
scope: 'user' | 'system';
|
|
30
|
+
mechanism?: string;
|
|
31
|
+
reportedAt: string;
|
|
32
|
+
}
|
|
33
|
+
export interface SystemHooksLeg {
|
|
34
|
+
installed: boolean;
|
|
35
|
+
path?: string;
|
|
36
|
+
reportedAt: string;
|
|
37
|
+
}
|
|
38
|
+
export interface EnforcementState {
|
|
39
|
+
fingerprint: string;
|
|
40
|
+
hostname: string;
|
|
41
|
+
platform: string;
|
|
42
|
+
cliVersion: string;
|
|
43
|
+
firewall?: FirewallLeg;
|
|
44
|
+
caTrust?: CaTrustLeg;
|
|
45
|
+
systemHooks?: SystemHooksLeg;
|
|
46
|
+
}
|
|
47
|
+
/** The legs a single write can update. Omitted legs are preserved from the existing file, not blanked. */
|
|
48
|
+
export type EnforcementStateLegs = Pick<EnforcementState, 'firewall' | 'caTrust' | 'systemHooks'>;
|
|
49
|
+
/** Machine-wide (not per-user) system-config location, per platform convention. */
|
|
50
|
+
export declare function enforcementStatePath(platform?: NodeJS.Platform): string;
|
|
51
|
+
/**
|
|
52
|
+
* Stable per-machine fingerprint: sha256 of hostname + platform + a
|
|
53
|
+
* platform machine-id source, truncated to 32 hex chars. Falls back to
|
|
54
|
+
* hostname + platform alone when the machine-id source is unavailable
|
|
55
|
+
* (sandboxed CI, no `ioreg`/`reg`, missing `/etc/machine-id`) — still
|
|
56
|
+
* stable across calls on the same box, just weaker at distinguishing two
|
|
57
|
+
* machines that happen to share a hostname.
|
|
58
|
+
*/
|
|
59
|
+
export declare function computeFingerprint(platform?: NodeJS.Platform): Promise<string>;
|
|
60
|
+
/** Reads the local enforcement state file, if present. */
|
|
61
|
+
export declare function readEnforcementState(path?: string): Promise<EnforcementState | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Merge-writes one or more legs into the local enforcement state file.
|
|
64
|
+
* Never overwrites a leg the caller didn't pass — a firewall-only write
|
|
65
|
+
* (from `enforce apply`) must not blank out a previously-recorded
|
|
66
|
+
* CA-trust leg (from `enterprise install`), and vice versa.
|
|
67
|
+
*/
|
|
68
|
+
export declare function writeEnforcementState(legs: EnforcementStateLegs, cliVersion: string, path?: string): Promise<EnforcementState>;
|
|
69
|
+
//# sourceMappingURL=enforcementState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enforcementState.d.ts","sourceRoot":"","sources":["../../src/lib/enforcementState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAWH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM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0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local, unprivileged-readable record of a machine's enforcement posture —
|
|
3
|
+
* firewall, CA trust, system hooks. Solves two problems together:
|
|
4
|
+
*
|
|
5
|
+
* 1. `intutic enforce status` needs root to query the underlying firewall
|
|
6
|
+
* tool (e.g. `pfctl`) on macOS, so an unprivileged run can't truthfully
|
|
7
|
+
* answer "is enforcement actually on?".
|
|
8
|
+
* 2. A `sudo`-elevated process can't read the real user's stored API
|
|
9
|
+
* credentials (Keychain-backed on macOS), so it can't itself report
|
|
10
|
+
* posture to the control plane.
|
|
11
|
+
*
|
|
12
|
+
* So: the privileged action (`enforce apply/remove`, `enterprise install`)
|
|
13
|
+
* records the truth here, locally, as it happens; a separate, unprivileged
|
|
14
|
+
* step (`enforce report`, `connect.ts`'s periodic loop — see A7) reads this
|
|
15
|
+
* file and ships it.
|
|
16
|
+
*
|
|
17
|
+
* World-readable, no secrets in it — device posture only.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import { readFile, writeFile, mkdir, rename } from 'node:fs/promises';
|
|
22
|
+
import { dirname } from 'node:path';
|
|
23
|
+
import { hostname } from 'node:os';
|
|
24
|
+
import { execFile } from 'node:child_process';
|
|
25
|
+
import { promisify } from 'node:util';
|
|
26
|
+
import { createHash } from 'node:crypto';
|
|
27
|
+
const execFileAsync = promisify(execFile);
|
|
28
|
+
/** Machine-wide (not per-user) system-config location, per platform convention. */
|
|
29
|
+
export function enforcementStatePath(platform = process.platform) {
|
|
30
|
+
if (platform === 'darwin')
|
|
31
|
+
return '/Library/Application Support/Intutic/enforcement-state.json';
|
|
32
|
+
if (platform === 'win32') {
|
|
33
|
+
return `${process.env.ProgramData ?? 'C:\\ProgramData'}\\Intutic\\enforcement-state.json`;
|
|
34
|
+
}
|
|
35
|
+
return '/var/lib/intutic/enforcement-state.json';
|
|
36
|
+
}
|
|
37
|
+
async function readMachineId(platform) {
|
|
38
|
+
try {
|
|
39
|
+
if (platform === 'linux') {
|
|
40
|
+
const id = (await readFile('/etc/machine-id', 'utf-8')).trim();
|
|
41
|
+
return id || null;
|
|
42
|
+
}
|
|
43
|
+
if (platform === 'darwin') {
|
|
44
|
+
const { stdout } = await execFileAsync('ioreg', ['-rd1', '-c', 'IOPlatformExpertDevice']);
|
|
45
|
+
const match = stdout.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);
|
|
46
|
+
return match?.[1] ?? null;
|
|
47
|
+
}
|
|
48
|
+
if (platform === 'win32') {
|
|
49
|
+
const { stdout } = await execFileAsync('reg', [
|
|
50
|
+
'query',
|
|
51
|
+
'HKLM\\SOFTWARE\\Microsoft\\Cryptography',
|
|
52
|
+
'/v',
|
|
53
|
+
'MachineGuid',
|
|
54
|
+
]);
|
|
55
|
+
const match = stdout.match(/MachineGuid\s+REG_SZ\s+([0-9a-fA-F-]+)/);
|
|
56
|
+
return match?.[1] ?? null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Stable per-machine fingerprint: sha256 of hostname + platform + a
|
|
66
|
+
* platform machine-id source, truncated to 32 hex chars. Falls back to
|
|
67
|
+
* hostname + platform alone when the machine-id source is unavailable
|
|
68
|
+
* (sandboxed CI, no `ioreg`/`reg`, missing `/etc/machine-id`) — still
|
|
69
|
+
* stable across calls on the same box, just weaker at distinguishing two
|
|
70
|
+
* machines that happen to share a hostname.
|
|
71
|
+
*/
|
|
72
|
+
export async function computeFingerprint(platform = process.platform) {
|
|
73
|
+
const machineId = await readMachineId(platform);
|
|
74
|
+
const material = machineId ? `${hostname()}:${platform}:${machineId}` : `${hostname()}:${platform}`;
|
|
75
|
+
return createHash('sha256').update(material).digest('hex').slice(0, 32);
|
|
76
|
+
}
|
|
77
|
+
async function readState(path) {
|
|
78
|
+
try {
|
|
79
|
+
return JSON.parse(await readFile(path, 'utf-8'));
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Reads the local enforcement state file, if present. */
|
|
86
|
+
export async function readEnforcementState(path = enforcementStatePath()) {
|
|
87
|
+
return readState(path);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Merge-writes one or more legs into the local enforcement state file.
|
|
91
|
+
* Never overwrites a leg the caller didn't pass — a firewall-only write
|
|
92
|
+
* (from `enforce apply`) must not blank out a previously-recorded
|
|
93
|
+
* CA-trust leg (from `enterprise install`), and vice versa.
|
|
94
|
+
*/
|
|
95
|
+
export async function writeEnforcementState(legs, cliVersion, path = enforcementStatePath()) {
|
|
96
|
+
const existing = await readState(path);
|
|
97
|
+
const fingerprint = existing?.fingerprint ?? (await computeFingerprint());
|
|
98
|
+
const next = {
|
|
99
|
+
fingerprint,
|
|
100
|
+
hostname: hostname(),
|
|
101
|
+
platform: process.platform,
|
|
102
|
+
cliVersion,
|
|
103
|
+
firewall: legs.firewall ?? existing?.firewall,
|
|
104
|
+
caTrust: legs.caTrust ?? existing?.caTrust,
|
|
105
|
+
systemHooks: legs.systemHooks ?? existing?.systemHooks,
|
|
106
|
+
};
|
|
107
|
+
await mkdir(dirname(path), { recursive: true });
|
|
108
|
+
const tmp = `${path}.intutic-tmp`;
|
|
109
|
+
await writeFile(tmp, JSON.stringify(next, null, 2) + '\n', { mode: 0o644 });
|
|
110
|
+
await rename(tmp, path);
|
|
111
|
+
return next;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=enforcementState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enforcementState.js","sourceRoot":"","sources":["../../src/lib/enforcementState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAA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AAA;IAChB,yEAAyE;IACzE,GAAG,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;CAC/C;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,SAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"ensureValkey.d.ts","sourceRoot":"","sources":["../../src/lib/ensureValkey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,IAAI,SAAO,EAAE,IAAI,SAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAajF;AAoBD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,yEAAyE;IACzE,GAAG,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;CAC/C;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,SAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAiF3E;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,IAAI,SAAO,GAAG,MAAM,CAQrD"}
|
package/dist/lib/ensureValkey.js
CHANGED
|
@@ -94,7 +94,7 @@ export async function ensureValkey(port = 6379) {
|
|
|
94
94
|
log.warn('Started the container but nothing answered on the port.');
|
|
95
95
|
}
|
|
96
96
|
catch (err) {
|
|
97
|
-
log.warn(`Could not start Valkey via Docker: ${err.message}`);
|
|
97
|
+
log.warn(`Could not start Valkey via Docker: ${err instanceof Error ? err.message : String(err)}`);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -122,7 +122,7 @@ export async function ensureValkey(port = 6379) {
|
|
|
122
122
|
log.warn(`Spawned ${nativeCmd} but nothing answered on the port.`);
|
|
123
123
|
}
|
|
124
124
|
catch (err) {
|
|
125
|
-
log.warn(`Could not spawn ${nativeCmd}: ${err.message}`);
|
|
125
|
+
log.warn(`Could not spawn ${nativeCmd}: ${err instanceof Error ? err.message : String(err)}`);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
return { running: false, via: 'none' };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureValkey.js","sourceRoot":"","sources":["../../src/lib/ensureValkey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,iFAAiF;AACjF,MAAM,UAAU,eAAe,CAAC,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,WAAW;IAC7D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAA;QACpC,MAAM,IAAI,GAAG,CAAC,MAAe,EAAE,EAAE;YAC/B,MAAM,CAAC,OAAO,EAAE,CAAA;YAChB,OAAO,CAAC,MAAM,CAAC,CAAA;QACjB,CAAC,CAAA;QACD,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QACxB,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACxC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;QACzC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;QACvC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,0DAA0D;AAC1D,KAAK,UAAU,aAAa,CAAC,IAAY,EA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;CAI7B;AAED,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,IAAI,EAAE,MAAM;CAIzB;
|
|
1
|
+
{"version":3,"file":"envInjector.d.ts","sourceRoot":"","sources":["../../src/lib/envInjector.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAG,MAAM,CAAC,QAAQ,CAAA;IAC1B,KAAK,EAAM,QAAQ,GAAG,MAAM,CAAA;IAC5B,IAAI,EAAO,MAAM,EAAE,CAAA;IACnB,MAAM,EAAK,MAAM,CAAA;CAClB;AAED,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,QAAQ,EAAE,MAAM;CAI7B;AAED,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,IAAI,EAAE,MAAM;CAIzB;AAsED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAwCrF;AAED;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiB1D"}
|
package/dist/lib/envInjector.js
CHANGED
|
@@ -41,7 +41,11 @@ function macosRemove(key) {
|
|
|
41
41
|
try {
|
|
42
42
|
execSync(`launchctl unsetenv ${key}`, { stdio: 'pipe' });
|
|
43
43
|
}
|
|
44
|
-
catch {
|
|
44
|
+
catch {
|
|
45
|
+
// Removal is idempotent by contract: `launchctl unsetenv` exits non-zero when
|
|
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.
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
function linuxInjectUser(key, value) {
|
|
47
51
|
const rcFile = path.join(os.homedir(), '.bashrc');
|
|
@@ -51,7 +55,14 @@ function linuxInjectUser(key, value) {
|
|
|
51
55
|
try {
|
|
52
56
|
content = fs.readFileSync(rcFile, 'utf8');
|
|
53
57
|
}
|
|
54
|
-
catch {
|
|
58
|
+
catch {
|
|
59
|
+
// A missing ~/.bashrc is the normal first-run case: `content` stays '' and the
|
|
60
|
+
// write below creates the file.
|
|
61
|
+
// CAUTION: this also swallows non-ENOENT read failures (EACCES, EISDIR, a
|
|
62
|
+
// symlink loop), and the write below then replaces the user's .bashrc with the
|
|
63
|
+
// single export line. Narrowing this to ENOENT would be a behaviour change, so
|
|
64
|
+
// it is deliberately left alone here rather than fixed as lint cleanup.
|
|
65
|
+
}
|
|
55
66
|
// Remove existing entry for this key
|
|
56
67
|
const lines = content.split('\n').filter(l => !l.includes(marker));
|
|
57
68
|
lines.push(line);
|
|
@@ -65,7 +76,11 @@ function linuxRemoveUser(key) {
|
|
|
65
76
|
const filtered = content.split('\n').filter(l => !l.includes(marker)).join('\n');
|
|
66
77
|
fs.writeFileSync(rcFile, filtered + '\n', { mode: 0o644 });
|
|
67
78
|
}
|
|
68
|
-
catch {
|
|
79
|
+
catch {
|
|
80
|
+
// Nothing to remove if ~/.bashrc does not exist, and an unwritable rc file must
|
|
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.
|
|
83
|
+
}
|
|
69
84
|
}
|
|
70
85
|
function windowsInject(key, value) {
|
|
71
86
|
execSync(`setx ${key} "${sanitizeShellValue(value)}"`, { stdio: 'pipe' });
|
|
@@ -74,7 +89,10 @@ function windowsRemove(key) {
|
|
|
74
89
|
try {
|
|
75
90
|
execSync(`reg delete HKCU\\Environment /v ${key} /f`, { stdio: 'pipe' });
|
|
76
91
|
}
|
|
77
|
-
catch {
|
|
92
|
+
catch {
|
|
93
|
+
// `reg delete` exits 1 with "unable to find the specified registry key or value"
|
|
94
|
+
// when the value is already gone. Removal is idempotent, so absence is success.
|
|
95
|
+
}
|
|
78
96
|
}
|
|
79
97
|
/**
|
|
80
98
|
* Injects ANTHROPIC_BASE_URL and OPENAI_BASE_URL as persistent env vars.
|